android intent filter浏览器应用的设置,如何使用choose-box选择应用

//使用chooserIntent
private void startImplicitActivation() { Log.i(TAG, "Entered startImplicitActivation()"); // TODO - Create a base intent for viewing a URL // (HINT: second parameter uses Uri.parse()) Uri myUri = Uri.parse(URL); Intent baseIntent = new Intent(Intent.ACTION_VIEW, myUri); // TODO - Create a chooser intent, for choosing which Activity // will carry out the baseIntent // (HINT: Use the Intent class' createChooser() method) Intent chooserIntent = Intent.createChooser(baseIntent, "Display this url via .."); Log.i(TAG,"Chooser Intent Action:" + chooserIntent.getAction()); // TODO - Start the chooser Activity, using the chooser intent startActivity(chooserIntent); }

设置Intent-filter

1             <!-- TODO - Add necessary intent filter information so that this
2                     Activity will accept Intents with the
3                     action "android.intent.action.VIEW" and with an "http"
4                     schemed URL -->
5             <intent-filter>
6                 <action android:name="android.intent.action.VIEW" />
7                 <category android:name="android.intent.category.DEFAULT" />
8                 <data android:scheme="http"/>
9             </intent-filter>

 

posted @ 2015-07-23 15:09  一梦轻枫  阅读(776)  评论(0编辑  收藏  举报