Online Find an article about: for different applications, use different ways of articles. Original Address
String contentdetails = ""; String Contentbrief= ""; String Shareurl= ""; Intent it=NewIntent (intent.action_send); It.settype ("Text/plain"); List<ResolveInfo> resinfo = Getpackagemanager (). Queryintentactivities (IT, 0); if(!Resinfo.isempty ()) {List<Intent> targetedshareintents =NewArraylist<intent>(); for(ResolveInfo info:resinfo) {Intent targeted=NewIntent (intent.action_send); Targeted.settype ("Text/plain"); Activityinfo Activityinfo=Info.activityinfo; //judgments:activityInfo.packageName, Activityinfo.name, etc. if(ActivityInfo.packageName.contains ("bluetooth") | | activityInfo.name.contains ("bluetooth")) { Continue; } if(ActivityInfo.packageName.contains ("GM") | | ActivityInfo.name.contains ("Mail") {Targeted.putextra (Intent.extra_text, contentdetails); } Else if(ActivityInfo.packageName.contains ("zxing") {Targeted.putextra (Intent.extra_text, Shareurl); } Else{Targeted.putextra (Intent.extra_text, contentbrief); } targeted.setpackage (Activityinfo.packagename); Targetedshareintents.add (targeted); } Intent chooserintent= Intent.createchooser (targetedshareintents.remove (0), "Select app to share"); if(Chooserintent = =NULL) { return; } //A parcelable[] of Intent or Labeledintent objects as set with//PutExtra (String, parcelable[]) of additional activities to place//a The front of the list of choices, when shown to the user with a//Action_chooser.Chooserintent.putextra (Intent.extra_initial_intents, Targetedshareintents.toarray (New( parcelable[] {})); Try{startactivity (chooserintent); } Catch(Android.content.ActivityNotFoundException ex) {Toast.maketext ( This, "Can ' t find share component to share", Toast.length_short). Show (); } }
Android sharing, how to filter the specified app, and send different content to different sharing mode?