Question :
I want to get the latest version of my app in production, from Google Playstore. I want to add functionality to force upgrade, if some changes in the latest version require it.
What I have :
I am currently updating the latest version of the app on my server, and forcing the app to request for it and check the version against it. This works. But I do not want to update on my server everytime I release a new version. I want the app to be able to pick up the same information from Google Playstore instead.
What I need :
I can handle the logic at client side (on the app). All I need is an API call to Playstore to get my own app's latest production version. If anyone can help me with some pointers on this, it would be very helpful.
Cheers,
Rohitesh
Tap on the app info icon (i), and you'll end up in Settings. You'll be in App info for that app; tap on the Advanced dropdown menu. At the bottom, you'll see what version you are using for that app.
Open Play Console. Select an app. On the left menu, select Release > Internal testing > Internal app sharing. On the Uploaders and testers tab, scroll to the “Manage testers” section and check that the option “Anyone you shared the link with can download” is selected (it should be selected by default).
You can check it with Android in-app-update. Android dev guide
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;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With