How to open Google Play Store App from my app to install the latest version of my app available on play store

拟墨画扇 提交于 2019-12-23 12:26:08

问题


I have a question regarding the app upgrade scenario from the app. Basically I am sending the app version from app to application server and then deciding whether to show the app upgrade reminder screen or not. App upgrade reminder screen has 2 options "update now" or "ignore".

Requirement is Update Now should open play store app with my app already searched on it.

I implemented following code :

try {
    startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appName)));
} catch (android.content.ActivityNotFoundException anfe) {
    startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id=" + appName)));
}

There are 2 problems with it :

1) It opens play store on top of my App. I need play store app to open separately and my app should still be alive.

2) Play store shows only 2 options (Uninstall and Open). It doesn;t give option to update the app.

Can someone please throw some direction to it.


回答1:


I would recommend against what you are trying to do. Is there a reason you need to notify users in app to update? The Play Store will notify them, and even automatically update your app in the background if there is an update.

Keep in mind that the Play Store rolls out your app updates. It's possible that you could redirect the user to the Play Store to update your app, and the update isn't yet available for them. This isn't usually a huge time frame, but it exists.

If you must do it, then to accomplish your first request you could add the new task flag to the intent. This will make the new activity launch as a new task in the history.

try {
    Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appName));
    i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(i);
} catch (android.content.ActivityNotFoundException anfe) {
    ...
}

The second issue you're having is because you have the latest version installed. If there is, in fact, an update available then you will get buttons saying "Update" and "Uninstall".




回答2:


1) From your code, if play store app is installed it will launch playstore with your app listed.

2) You get the update option in play store only if the current version installed in the phone is less than the version available in the play store.



来源:https://stackoverflow.com/questions/18838805/how-to-open-google-play-store-app-from-my-app-to-install-the-latest-version-of-m

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!