I tried this
private void postImage(Uri uri) {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_SEND);
intent.setType("image/*");
intent.addCategory(Intent.CATEGORY_DEFAULT);
intent.putExtra(Intent.EXTRA_TEXT, "My bracelet image");
intent.putExtra(Intent.EXTRA_TITLE, "Action Bracelet");
intent.putExtra(Intent.EXTRA_STREAM,uri);
Intent chooser=Intent.createChooser(intent,"Share Image Using");
try{
context.startActivity(chooser);
}
catch(ActivityNotFoundException e){
Toast.makeText(context,"You don't have any share application installed",Toast.LENGTH_SHORT).show();
Log.e("Image Load","failed");
}
}
Now my problem is i need the application name on which this image is shared .I also created my custom dialog for it but problem remains same . Because when i select an option for share like facebook and i pressed back button then image is not share and i only know that the user click on facebook. so i need a callback which gives me result_ok and result_cancle and the application name too . Can anyone help me i am stuck here from last three days ...
If your
minSdkVersion
is 22 or higher, use thecreateChooser()
that takes anIntentSender
as the third parameter, as that is your only means of finding out what the user chose.If your
minSdkVersion
is below 22, you will have to create your own chooser-style UI, usingPackageManager
andqueryIntentActivities()
to find out what activities should be listed in that UI.You certainly know what the user chose in the dialog. That is all you are going to get from the API Level 22
createChooser()
either.Of course. The user can do whatever the user wants in that other application. The user does not have to press BACK; the user can simply fail to send anything. That is between the user and that application — information about whether the user did anything, who the user shared the information with, and so on, is not available to you.