我已正確設置所有內容,但隱式活動未顯示應用程序選擇器,它表示沒有應用程序可以執行此操作(該URL是我想要打開的內容用戶選擇的應用程序)如何在Android中製作應用程序選擇器
這裏是我的MyBrowser xml文件:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
這裏是代碼創建的意圖和initalizing的appChooser:
private void startImplicitActivation() {
Log.i(TAG, "Entered startImplicitActivation()");
// TODO - Create a base intent for viewing a URL
// (HINT: second parameter uses parse() from the Uri class)
Intent viewer = new Intent(Intent.ACTION_VIEW,Uri.parse(URL));
// TODO - Create a chooser intent, for choosing which Activity
// will carry out the baseIntent. Store the Intent in the
// chooserIntent variable below. HINT: using the Intent class'
// createChooser())
Intent chooserIntent = Intent.createChooser(viewer, CHOOSER_TEXT);
Log.i(TAG,"Chooser Intent Action:" + chooserIntent.getAction());
// TODO - Start the chooser Activity, using the chooser intent
startActivity(chooserIntent);
}
我很困惑,因爲代碼對我來說看起來很清楚,但我不能爲了我的生活找出它爲什麼不起作用。
我認爲選擇器會直接轉發意圖,如果只有一個應用程序來處理它。 – flx
嗯,我試圖讓它使用Android的默認瀏覽器和MyBrowser作爲選擇,因爲它是一個網站地址。 – MrTimotheos