Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Intent setPackage for 2 or more specific app

Tags:

android

share

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?

like image 974
EES Avatar asked Jun 16 '14 09:06

EES


People also ask

How do I send Intent from one app to another?

Using the Android intent resolver The Android intent resolver is best used when sending data to another app as part of a well-defined task flow. To use the Android intent resolver, create an intent and add extras as you would if you were to call the Android Sharesheet. However, do not call Intent. createChooser() .

Is Intent deprecated?

The Intent is not deprecated the problem is with your itemClickable. class because it is not recognized.

What is setType in Intent Android?

Basically what it does is, it lets you set the type of data that you are using to send in an intent. You might also want to check out an existing question: Android - Intent.setType() arguments.


1 Answers

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?

like image 197
sergio91pt Avatar answered Oct 06 '22 12:10

sergio91pt