开发者

Android start intent to view apk

In 开发者_运维知识库my application I am downloading and saving an apk to the SDcard and then I want to start the installation of the apk. I'm using the following code to attempt this:

Intent intent =new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse(file), "application/vnd.android.package-archive");
activity.startActivity(intent);

But when I do this it tells me there is no activity to start the intent. What I am attempting to do is install a new update for the currently running application. How do I start an Intent to run an apk file?


Did you try using Uri.fromFile(new File(filePath)) instead of Uri.parse(file)?


Intent intent =new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse(file), "application/vnd.android.package-archive");
activity.startActivity(intent);
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜