I go through lot of link and tutorial such as Check if application is installed - Android and How to check programmatically if an application is installed or not in Android? but i didn't find exact solution of my issue. When i am trying to install a app whose launcher package is com.test.app then at time of installation i want to check this package or you can say our App is already installed or not? When i am trying to do as in above link it is showing always "installed" for me either it is installed or not. So how i will manage this.
Asked
Active
Viewed 138 times
0
-
ok i have solution for this,i am giving you a link that provides all the installed application name ,package name and other informations.You can check for a particular package name there.if you have any question tell me. – Rohit Goswami May 15 '14 at 11:50
-
try this http://stackoverflow.com/questions/23669277/how-to-get-all-homescreens-in-android/23670155#23670155 – Rohit Goswami May 15 '14 at 11:51
-
First you deserve.. my thanks for quick response... – DJhon May 15 '14 at 11:52
-
Hey gopal RAO.. Is it possible to check App "A" is installed or not during instalaation of App "A"....? By use some SYSTEM_SERVICE is it possible? I don't have idea about it.... – DJhon May 15 '14 at 13:23
-
Yes i get it.. I can do it by use of web-services. Thanks to all.. – DJhon May 16 '14 at 06:02
-
@BlueGreen if possible, can you share your code how it can be done? – Gopal Gopi May 16 '14 at 06:40
-
@GopalRao..Sorry for delay..I update my answer – DJhon May 19 '14 at 10:43
1 Answers
0
This is an idea . Which i have implemented
1. Create a Web Service which our app can pull whenever the app
launches or based on some time limit that can check if there is new version out there.
2. This Web service should return the latest Version of the apk file that is hosted on the
Server along with the URI of the application file that has the new version.
3. When your app gets the response from the Web Service, it will parse the JSON and
check our app version to the latest version that is available
on the server.
4. If our app version is lower than the latest version it will prompt
the user to start the download process.
5. Today i manage download process by the Download Manager and day before
yesterday I do same thing by Package Manager. I will update which mechanism is
most optimal to download .apk file with size of more than 10MB.
6. The download manager will notify our app using Broadcast receiver when the download
is complete.
7. Upon completion of the latest version of the application file the we can
start the activity to install that file.
Then we can compare version by
private static int compare(String v1, String v2) {
String s1 = normalisedVersion(v1);
String s2 = normalisedVersion(v2);
int cmp = s1.compareTo(s2);
System.out.println("cmp int "+cmp);
return cmp;
/* String cmpStr = cmp < 0 ? "<" : cmp > 0 ? ">" : "==";
System.out.printf("'%s' %s '%s'%n", v1, cmpStr, v2);*/
}
and then
public static String normalisedVersion(String version) {
return normalisedVersion(version, ".", 4);
}
public static String normalisedVersion(String version, String sep, int maxWidth) {
String[] split = Pattern.compile(sep, Pattern.LITERAL).split(version);
StringBuilder sb = new StringBuilder();
for (String s : split) {
sb.append(String.format("%" + maxWidth + 's', s));
}
return sb.toString();
}

DJhon
- 1,548
- 3
- 22
- 39
-
-
In general, GooglePlay app will take care about the updating apps in a real device. We no need to manually check for updates of our app as it is a responsibility of GooglePlay app. and I can't say whether it is feasible or not as I never came across this type of situation... – Gopal Gopi May 22 '14 at 04:56
-