-1

I am trying to Show update alert inside my application if i had update in my google play app, following this as reference i have managed to get response from the play store. But the response from play-store to look update getting like this .

We're sorry, the requested URL was not found on this server

My question is how i know inside my app if update available in google play-store ?

and google play do't support the private update link in the apk, so is there any other ways to get the update inside app from playstore. Thanks in advance.

Sree
  • 2,968
  • 2
  • 28
  • 38

1 Answers1

1

Depending on how often you'll be doing an update, you could simply have a page on your server that gives you the latest version available, and if it doesn't match the current one, prompt the user with an intent that opens the play store at your app.

Basically, ask the server what the latest version is (you'll need to wrap this in a try/catch and add the internet permission to the manifest):

URL url = new URL("mysite.com/thefile.txt");
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
String str;
while ((str = in.readLine()) != null) {
    // str is one line of text; readLine() strips the newline character(s)
}
in.close();

The response from the server could be something like {"latestVersion": "1.004"} and you can check the current installed version with:

PackageInfo pInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
version = pInfo.versionName;

Compare them, and prompt the user with a dialog or whatever and then launch the play store, by using the code found here:

final String appPackageName = getPackageName(); // getPackageName() from Context or Activity object
try {
    startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName)));
} catch (android.content.ActivityNotFoundException anfe) {
    startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id=" + appPackageName)));
}

To clarify, you'll be updating the version in your server manually so that may or may not be an option for you depending on the frequency of your updates, and how often you forget things :P

Community
  • 1
  • 1
Juan Cortés
  • 18,689
  • 8
  • 63
  • 88
  • can you able to tell me how i can get the response from the server like you said, all the other part i am doing but i am failing in the place of getting the response. – Sree May 21 '14 at 06:23
  • i am sorry to ask, can i know what is this `thefile.txt` in google play store ? – Sree May 21 '14 at 06:37
  • As I said, it's a file on Your server, not in playstore – Juan Cortés May 21 '14 at 07:12
  • ok thank-you for your help.I am looking some thing other like update directly from playstore – Sree May 21 '14 at 08:05