//使用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>
时间: 2024-10-03 19:28:19