Take Weibo sharing as an example:
1.public void Onclickshare (view view) { 2. 3. Intent intent=new Intent (intent.action_send); 4. Intent.settype ("image/*"); 5. Intent.putextra (Intent.extra_subject, "share"); 6. Intent.putextra (Intent.extra_text, "finally can!!!"); 7. intent.setflags (intent.flag_activity_new_task); 8. startactivity (Intent.createchooser (Intent, GetTitle ())); 9. 10.
It uses intent.action_send and MIME types to find all data picker that support image/*, allowing the user to select one of them.
We can make our activity appear in the picker.
<activity android:name= ". Testactivity "
Android:label= "Testactivity" >
<intent-filter>
<action android:name= "Android.intent.action.GET_CONTENT"/>
<category android:name= "Android.intent.category.DEFAULT"/>
<category android:name= "Android.intent.category.OPENABLE"/>
<data android:mimetype= "Audio/music1"/>
</intent-filter>
</activity>
Intent.action_chooser = "Android.intent.action.CHOOSER" Its function is to display an activity selector.
Intent provides a static Createchooser method that makes it easier to create such a intent