android.content.ActivityNotFoundException: No Activity found to handle Intent

本文介绍了在Android开发中调用系统Intent时遇到“NoActivityfoundtohandleIntent”错误的原因及解决方案,包括访问网页、地图和安装APK的具体实现方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

当调用系统Intent时,以调用以下2种Intent出现:No Activity found to handle Intent出错提示时,主要的原因及解决办法:

1、访问浏览器:

Uri uri = uri.parse("www.google.com");

Intent intent = new Intent(Intent.ACTION_VIEW,uri);

startActivity(intent);

原因:网址前面未加http导致的,访问的网址必须是完整的网址,不能省略http。

2、访问地图:

Uri uri = Uri.parse("geo:39.82,116.46");

Intent intent1 = new Intent(Intent.ACTION_VIEW,uri);

startActivity(intent1);

原因:模拟器上没有查看地图的软件,因此会出错,真机上一般都有查看地图的软件,所以在真机上不会出错。

3、如果是启动SD卡里面的apk包安装,则需要加上"file://" + apk包的路径名字

一般写法:

Intent intent = new Intent(Intent.ACTION_VIEW);

intent.setDataAndType(Uri.parse("file://" + Environment.getExternalStorageDirectory().getAbsolutePath()+"/UpdateDemo.apk"),"application/vnd.android.package-archive");
startActivity(intent);

同时还需要对配置文件设置权限,使其能够获取写入SD卡的权限。

参考:http://blog.youkuaiyun.com/aminfo/article/details/7738346


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值