028-86922220

建站动态

根据您的个性需求进行定制 先人一步 抢占小程序红利时代

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

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();
}

网站题目:通过Intent使用第三方应用打开
网站地址:http://www.tsicrk.com/article/ggjdgh.html

其他资讯

让你的专属顾问为你服务

3.5710s