androidshare

Android Intent setPackage for 2 or more specific app


From this SO answer, I can set the Intent to a specific app by setPackage. For my scenario I need to share text to either WhatsApp, Instagram or Line. Is it possible to set more than one package bundle ID?


Solution

  • It isn't possible. What you can do is to call setPackage(String) for one of them, send it and then rinse and repeat.

    You may want to use PackageManager to see if the apps are installed, but from a security view point setPackage is not secure, because any app can use WhatsApp, Instagram,.. packages if they're not already installed. Assuming the intent is for a broadcast, maybe you should consider using an implicit intent as other apps may be interested?