In Android sharing, how does one filter out specified applications, filter Bluetooth, and send different content to different sharing methods?

Source: Internet
Author: User

 

 

String contentdetails = "friends come and play *** game handle"; intent = new intent (intent. action_send); // enable the intent attribute for sharing and sending. settype ("text/plain"); intent. settype ("image/*"); // list of Image Sharing information types <resolveinfo> resinfo = getpackagemanager (). queryintentactivities (intent, 0); If (! Resinfo. isempty () {list <intent> targetedincluintents = new arraylist <intent> (); For (resolveinfo info: resinfo) {intent targeted = new intent (intent. action_send); intent. settype ("image/*"); // share the image information type targeted. settype ("text/plain"); activityinfo = info. activityinfo; If (activityinfo. packagename. contains ("Bluetooth") | activityinfo. name. contains ("Bluetooth") {continue; // filter Bluetooth applications} If (activityinfo. packagename. contains ("com. my. activity ") | activityinfo. name. contains ("com. my. activity ") {continue; // filter your application package} 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, contentdetails);} else {targeted. putextra (intent. extra_text, contentdetails);} targeted. setpackage (activityinfo. packagename); targetedshareintents. add (targeted);} // the title of the Sharing box intent chooserintent = intent. createchooser (targetedshareintents. remove (0), "Select Program sharing"); If (chooserintent = NULL) {return;} chooserintent. putextra (intent. extra_initial_intents, targetedshareintents. toarray (New parcelable [] {}); try {startactivity (chooserintent);} catch (Android. content. activitynotfoundexception ex) {toast. maketext (activity_aboutme.this, "shared application not found", toast. length_short ). show ();}}

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.