0
我正在開發一個Android Coursera作業,以使用隱式意圖在瀏覽器中打開鏈接。在代碼中,我有一個選擇器方法,可以讓用戶選擇使用哪種瀏覽器。但問題是沒有使用CATEGORY Browsable選項的瀏覽器。請看看我的代碼:意圖在瀏覽器中打開不工作的鏈接
private void startImplicitActivation() {
Log.i(TAG, "Entered startImplicitActivation()");
// TODO - Create a base intent for viewing a URL
// (HINT: second parameter uses Uri.parse())
String url = "https://www.google.com";
Intent baseIntent = new Intent(Intent.CATEGORY_BROWSABLE, Uri.parse(url));
// TODO - Create a chooser intent, for choosing which Activity
// will carry out the baseIntent
// (HINT: Use the Intent class' createChooser() method)
Intent chooserIntent = new Intent(Intent.createChooser(baseIntent, "Select Your Browser"));
Log.i(TAG,"Chooser Intent Action:" + chooserIntent.getAction());
// TODO - Start the chooser Activity, using the chooser intent
startActivity(chooserIntent);
}
在活動啓動時產生的輸出低於(我不明白爲什麼沒有瀏覽器上來):
[發送意向到瀏覽器以打開特定URL]可能的重複(http://stackoverflow.com/questions/3004515/sending-an-intent-to-browser-to-open-specific-url) – AxelH