Android的意图开始查看APK [英] Android start intent to view apk

查看:145
本文介绍了Android的意图开始查看APK的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序,我下载并保存一个APK的SDK卡,然后我要开始的APK安装。我用下面的code尝试这样的:

In my application I am downloading and saving an apk to the sdk card 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);

但是,当我做到这一点告诉我,有没有活动启动的意图。我所试图做的就是安装新的更新为当前运行的应用程序。我该如何开始的意图来运行apk文件?

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?

推荐答案

你有没有尝试使用 Uri.fromFile(新File(文件路径))而不是 Uri.parse(文件)

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

这篇关于Android的意图开始查看APK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆