Android – how do I open the Google play store app from my app to install the latest version of my app in the play store

I have questions about the application upgrade scheme in the application. Basically, I send the application version from the app to the application server, and then decide whether to display the application upgrade reminder screen. The application upgrade reminder screen has two options "update now" or "ignore"

The requirement is to update immediately. The player store app should be opened. My app has searched on it

I implemented the 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)));
}

It has two problems:

1) It opens the game store at the top of my app. I need to open the game store app separately. My app should still be alive

2) The play store only displays 2 options (uninstall and open). It does not provide the option to update the application

Someone can give it some instructions

resolvent:

I will not recommend what you want to do. Do you need to notify users of updates in the app? The play store will notify them that if there is an update, it will even automatically update your app in the background

Please note that the play store will launch your app updates. You can redirect users to the play store to update your app and can't provide them with updates yet. This is usually not a huge time frame, but it exists

If you have to do so, to complete your first request, you can add the new task flag to the intention. This will make the start of a new activity a new task in 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 problem you encounter is that you have the latest version installed. In fact, if an update is available, you will get the update and uninstall buttons

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>