How to tell which app was selected by Intent.createChooser?
On Android 5.1+, you can use the three-parameter edition of the createChooser()
method, where the last parameter is an IntentSender
that you can use to find out what was chosen.
Prior to Android 5.1, there is nothing in Android to let you know what the user chose.
How to know which intent is selected in Intent.ACTION_SEND?
You can't get such information.
Unless you create your own implementation of the dialog for the activity selection.
To create such dialog you need to use PackageManager
and its queryIntentActivities()
function. The function returns List<ResolveInfo>
.
ResolveInfo
contains some information about an activity (resolveInfo.activityInfo.packageName
), and with the help of PackageManager
you can get other information (useful for displaying the activity in the dialog) - application icon drawable, application label, ... .
Display the results in a list in a dialog (or in an activity styled as a dialog). When an item is clicked create new Intent.ACTION_SEND, add the content you want and add the package of the selected activity (intent.setPackage(pkgName)
).
Is it possible to detect if an ACTION_SEND Intent suceeded?
Is there a way to read an intent response?
Not from an arbitrary activity for an arbitrary action.
The documentation for Intent
actions will tell you if there is expected output or not. So, for example, ACTION_GET_CONTENT
is documented to have output. For those Intent
actions, you use startActivityForResult()
, and part of the output will be a "result code" to let you know generally what the result was.
However:
Not every
Intent
action is documented to have output. Notably,ACTION_SEND
is not documented to have output. In that case, you don't usestartActivityForResult()
(but instead usestartActivity()
). Even if you do usestartActivityForResult()
, you have no way to know if a negative outcome means that the user cancelled out or if the other activity simply is following the documentation and did not return a result.Some activities are buggy and fail to return results when they should.
Your definition of a successful result and the activity's definition of a successful result may differ.
How to know which application the user chose when using an intent chooser?
As far as I know, there is no direct way to gather such information. What would you need it for? Imho the android intent system was designed so you, as an app developer, don't have to worry about what app the user chose to handle your intent.
How can I detect if user selected from createChooser options?
From Android's source, you can see that the Activity that chooses among Intents doesn't setResult() at all. That should be requested as a feature.
Related Topics
How to Combine Bottomappbar + Fab with Bottomnavigationview
How to Save File from Website to Sdcard
Android Ndk C++ Jni (No Implementation Found for Native...)
How to Disable Future Dates in Android Date Picker
Android: Picasso Load Image Failed . How to Show Error Message
How to Write Text Over a Picture in Android and Save It
Android Studio 4.1.1 MACos Full Screen Error
Eclipse Ddms Error "Can't Bind to Local 8600 for Debugger"
Can an Aar Include Transitive Dependencies
Understanding Android's <Layer-List>
Can't Upgrade Android Sdk Tools
How to Set Different Applicationid for Each Flavor Combination Using Flavordimensions
Pattern "One Activity, Multiple Views": Advantages and Disadvantages
Android Alternate Row Colors in Listview