通过 Intent使用第三方应用打开

发布时间:2020-07-23 08:25:31 作者:wangkai217
来源:网络 阅读:564
1、就算有默认应用程序也打开应用选择面板
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.addCategory("android.intent.category.DEFAULT");
Uri uri = Uri.fromFile(file);
intent.setDataAndType(uri, "p_w_picpath/*");
intent.setComponent(new ComponentName("android", "com.android.internal.app.ResolverActivity"));
context.startActivity(intent);
/*
*context.startActivity(Intent.createChooser(intent,"标题"));
*/


2、没有默认应用程序打应用选择面板,否则直接打开默认程序
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.addCategory("android.intent.category.DEFAULT");
intent.addCategory("android.intent.category.BROWSABLE");
Uri uri = Uri.parse(url);
intent.setData(uri);
try {
    context.startActivity(intent);
} catch (ActivityNotFoundException e) {
    Toast.makeText(context, "找不到浏览器", Toast.LENGTH_SHORT).show();
}
推荐阅读:
  1. aidl通过回调共享数据
  2. Cordova(PhoneGap)通过CordovaPlugin插件调用 Activity 实例

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

android 第三

上一篇:数据恢复前必读

下一篇:360 浏览器 不显示 bootstrap 字体图标问题

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》