Reputation: 193
want to use Android Intent.ACTION_SEND for quickly sharing something. i wrote some code and i can show custom shearing dialog but i want to check intent is selected in Intent.ACTION_SEND,for example if i send some files from Gmail i want to show Toast message( message sent from Gmail and etc) this is a my source
PackageManager pm = mActivity.getPackageManager();
Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
shareIntent.setType("image/jpeg");
Uri photoUri = Uri.parse(path);
shareIntent.putExtra(Intent.EXTRA_TEXT, "Downloading your app");
shareIntent.putExtra(Intent.EXTRA_STREAM, photoUri);
List<ResolveInfo> activityList = pm.queryIntentActivities(shareIntent, 0);
for (final ResolveInfo app : activityList)
{
Log.e("Application pachage",app.activityInfo.name +"package");
if ((app.activityInfo.name).contains("Bluetooth"))
{
Log.e("Application pachage","mee" +"package");
Toast.makeText(mActivity,"Message sent from Bluetooth",Toast.LENGTH_SHORT).show();
final ActivityInfo activity = app.activityInfo;
final ComponentName name = new ComponentName(activity.applicationInfo.packageName, activity.name);
shareIntent.addCategory(Intent.CATEGORY_LAUNCHER);
shareIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
shareIntent.setComponent(name);
mActivity.startActivity(shareIntent);
break;
}
}
So, is it possible to do that?
Upvotes: 2
Views: 756
Reputation: 1006664
Only on Android 5.1+, if you use the three-parameter flavor of createChooser()
, where you can supply an IntentSender
that is notified about the choice.
Otherwise, you would need to roll your own chooser-style UI, then use the user's choice to craft an explicit Intent
to route the user to the requested activity.
Upvotes: 2