I have a force update in my android application, where it checks the version name of my app on the play store and also, verifies with my app update. If the google play store version differs from the current version it displays a popup message for the update.
When the user presses the update button on the popup, it redirects to the play store. The issue is, on google play store, in some devices, the 'Update' button is not displayed and the 'Open' button is displayed.
I tried clearing the cache, and it worked. But it's not very convenient for the user to do the same. And on how many devices, do I have to keep doing this.
This is my code below, for verifying the app version:
protected String doInBackground(String... urls) {
try {
newVersion = Jsoup.connect("https://play.google.com/store/apps/details?id=" + <Your package name> + "&hl=en")
.timeout(30000)
.userAgent("Mozilla/5.0 (Windows; U; WindowsNT 5.1; en-US; rv1.8.1.6) Gecko/20070725 Firefox/2.0.0.6")
.referrer("http://www.google.com")
.get()
.select("div.hAyfc:nth-child(4) > span:nth-child(2) > div:nth-child(1) > span:nth-child(1)")
.first()
.ownText();
return newVersion;
} catch (Exception e) {
e.printStackTrace();
return "";
}
}
And this is the code for redirecting to google play store:
try {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setData(Uri.parse("market://details?id=" + context.getPackageName()));
startActivity(intent);
dialog.dismiss();
} catch (Exception e) {
e.printStackTrace();
}
As I have already told you that in some devices its working fine, while in some, I had to clear the Google Play Store cache.
What could be the desired solution?
Thanks in advance.