Android Studio:createChooser帮助
问题描述:
Android Studio新手在这里。 我有一个项目,当按下按钮时,它必须询问用户他们想要打开链接的位置:我的手机的默认浏览器或其他应用程序MyBrowser(它将通过MyBrowser打开浏览器)。但是,当我按下按钮时,它会自动将我带到我的手机的默认浏览器,而不会让用户有机会选择。 这里是我的代码:Android Studio:createChooser帮助
openWeb = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.amazon.com"));
Intent launchIntent = getPackageManager().getLaunchIntentForPackage("browser.school.mybrowser");
Intent chooser = Intent.createChooser(openWeb, "Please choose which browser...");
if (openWeb != null) {
startActivity(chooser);
}
if (launchIntent != null) {
startActivity(launchIntent);
}
谢谢!这正是我正在寻找的。 – futureLookingGrimm