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(); }
转载于:https://blog.51cto.com/wangkai217/1842143