There is a trick that you can implement for getting current play store version.
public void getUpdate() {
final String appPackageName = getPackageName();
Document doc = null;
try {
doc = Jsoup.connect("https://play.google.com/store/apps/details?id=" + appPackageName).get();
} catch (IOException e) {
e.printStackTrace();
}
// Document doc = Jsoup.parse(resString);
if(doc!=null) {
Element meta = doc.select("div[itemprop=softwareVersion]").first();
String content = meta.ownText();
System.out.println(content);
Double playStoreVersion = Double.valueOf(content);
Double currentVersion = getVersionName();
if (playStoreVersion > currentVersion) {
try {
new AlertDialog.Builder(SplashScreen.this)
.setTitle("Alert")
.setMessage("Update Is Available.Do You Want To Update?")
.setIcon(R.mipmap.ic_launcher)
.setCancelable(false)
.setPositiveButton("Update",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int id) {
try {
startActivityForResult(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName)), UPDATE_FROM_PLAY_STORE_REQUEST);
} catch (Exception e) {
try {
startActivityForResult(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + appPackageName)), UPDATE_FROM_PLAY_STORE_REQUEST);
} catch (Exception e1) {
}
}
dialog.dismiss();
}
}).setNegativeButton("Not yet", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
Handler();
}
}).show();
//startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + appPackageName)));
} catch (android.content.ActivityNotFoundException anfe) {
try {
startActivityForResult(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + appPackageName)), UPDATE_FROM_PLAY_STORE_REQUEST);
} catch (Exception e) {
}
}
} else {
Handler();
}
}else {
Handler();
}
}
get the version of our own application.
public Double getVersionName() {
Double VersionName = 0.0;
try {
String vName = SplashScreen.this.getPackageManager().getPackageInfo(SplashScreen.this.getPackageName(), 0).versionName;
VersionName = Double.valueOf(vName);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
return VersionName;
}