135-1821-9792

通过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://kswsj.com/article/ggjdgh.html

其他资讯



Copyright © 2009-2022 www.kswsj.com 成都快上网科技有限公司 版权所有 蜀ICP备19037934号