开发者

Android - About opening the Market from an application

开发者 https://www.devze.com 2023-04-03 13:53 出处:网络
In order to tell the user that a new version of an Android application is available, an AlertDialog is displayed asking the user to go on the Market in order to download the latest version.

In order to tell the user that a new version of an Android application is available, an AlertDialog is displayed asking the user to go on the Market in order to download the latest version.

The code responsible for sending the user to the Market is the following:

Intent intentMarket = new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.app_name)));
mContext.startActivity(intentMarket);

With this approach and given this, the Android Market activity takes the top of the back stack and if the user quits the Market without returning back to the application, when he comes back by clicking on the application icon, he finds himself on the Market and not on the application which can be ambiguous for him.

Is there any solution to this?

开发者_开发问答

Thanks!


You need to set the flag FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET. It's just a matter of:

intentMarket.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
0

精彩评论

暂无评论...
验证码 换一张
取 消