Android 自动更新APP时确定安装后没有显示安装完成页面

自动更新APP代码时,开始用的是以下代码

Intent intent = new Intent(Intent.ACTION_VIEW);        
        intent.setDataAndType(Uri.parse("file://"+Constants.SDK_DIR
				+File.separator+Constants.SDK_NAME), "application/vnd.android.package-archive");
        context.startActivity(intent);

但是,有的情况下,用这些代码时,在显示安装确认的对话框,点击确定后,直接退出。不显示完成更新页面(拥有打开,完成的页面),但是确实已经安装。

于是,我加上了一行代码,变成了

Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.setDataAndType(Uri.parse("file://"+Constants.SDK_DIR
				+File.separator+Constants.SDK_NAME), "application/vnd.android.package-archive");
        context.startActivity(intent);

于是正常了!

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。