-1

e.g If user clicks on check for update then action should be..

  • Check version of my application in market
  • If my application's current version and market version are not same then I just want to give a dialog of "Upgrade now".

Also wants to know is there any possibilities without WebServices for this aciton? because I have referred some answers with WebServices, instead of it is there any possibilities then please share your knowledge.

Thanks in advance :)

Kishan Soni
  • 816
  • 1
  • 6
  • 19

3 Answers3

0

You can't get version of android market app, I wanna explain this... You can get current version of the app with this code:

public int getAppVersion(Context context) {
    try {
        PackageInfo packageInfo = context.getPackageManager()
                .getPackageInfo(context.getPackageName(), 0);
        return packageInfo.versionCode;
    } catch (PackageManager.NameNotFoundException e) {
        // should never happen
        throw new RuntimeException("Could not get package name: " + e);
    }
}

If you want to know the version that have android market, that it's impossible, you need to think alternative, webservice how you say... In my case, for example, I save the version of Android Market in my server, when I sync my app with my server I obtain the AndroidMarket version then in this moment I can compare versions and apply the necessary code, in your case showDialog.

Not exist alternative that you can get version from you android app market, why? The apps have their code and not it's the same code for all apps...

Tell me if I helped you and good programming!

0
public String getLatestVersionNumber()
{
String versionNumber = "0.0.0";

try
{
    Document doc = Jsoup.connect("<market:urlofparticularapp>").get();
    Elements changeLog = doc.select("div.clDesc");

    for (Element div : changeLog)
    {
        String divText = div.text();

        if (divText.contains("Version"))
        {
            return divText.split(" ")[1];
        }

    }
}
catch (IOException e)
{
    e.printStackTrace();
}

return versionNumber;
}

Download Library of Jsoup from http://jsoup.org/download

Kishan Soni
  • 816
  • 1
  • 6
  • 19
-1

As I know there is no way to get current version of market Application.

But i am doing this in my application by using of server. I am putting the Upcoming app version on server and getting the current app version from app By using this code

oldVersion = Splash.this.getPackageManager().getPackageInfo(getPackageName(), 0).versionName;

When app will launch then we will get the version from server and compare with app version for old user. If version will mismatch then give the popup for update for application using this code

Uri uri = Uri.parse("market://details?id=" + MainActivity.this.getPackageName());

Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri);
                            try {
                                MainActivity.this.startActivity(goToMarket);
                            } catch (ActivityNotFoundException e) {
                                MainActivity.this.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id=" + MainActivity.this.getPackageName())));
                            }
Deepak
  • 131
  • 2
  • 12