目前我的应用程序具有更新功能,我无法在软件包安装程序后显示打开/完成的dilaog?还有其他选择然后建议我。谢谢: - )
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(new File(apkPath)), " application/vnd.android.package-archive");
ctx.startActivity(intent);
如何在安装包后显示打开/完成对话框?
答案 0 :(得分:0)
在onCreate()方法中,使用startActivityForResult
代替startActivity
&发送额外的1000作为requestCode
。您可以在onActivityResult()
方法&中获得该值。您可以在onActivityResult()
方法中显示成功或失败对话框,如下所示
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(new File(apkPath)), " application/vnd.android.package-archive");
startActivityForResult(intent, 1000); //1000 is RequestCode here
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// Check for resultCode == RESULT_OK & requestCode == 1000 conditions
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_OK && requestCode == 1000) {
System.out.println("Success Status");
} else {
System.out.println("Failure Status");
}
}