如何获取ACION_SEND意图的回调 [英] How to get callback of ACION_SEND Intent

查看:102
本文介绍了如何获取ACION_SEND意图的回调的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试过

 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");
            }
        }

现在我的问题是我需要共享此图像的应用程序名称.我也为此创建了自定义对话框,但是问题仍然相同.因为当我选择类似Facebook的共享选项并按下返回按钮时,则图像不共享,我只知道用户单击了Facebook. 所以我需要一个回调,它也给我result_ok和result_cancle以及应用程序名称.谁能帮帮我,我从最近三天开始就被困在这里...

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 ...

推荐答案

现在我的问题是我需要共享此图像的应用程序名称

Now my problem is i need the application name on which this image is shared

如果您的minSdkVersion为22或更高,请使用

If your minSdkVersion is 22 or higher, use the createChooser() that takes an IntentSender as the third parameter, as that is your only means of finding out what the user chose.

如果minSdkVersion低于22,则必须使用PackageManagerqueryIntentActivities()创建自己的选择器样式的UI,以找出应该在该UI中列出哪些活动.

If your minSdkVersion is below 22, you will have to create your own chooser-style UI, using PackageManager and queryIntentActivities() to find out what activities should be listed in that UI.

我也为此创建了自定义对话框,但问题仍然存在

I also created my custom dialog for it but problem remains same

您当然知道用户在对话框中选择了什么.这就是您将要从API Level 22 createChooser()获得的全部.

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.

因为当我为Facebook之类的共享选择一个选项并且按下返回按钮时,图像却没有共享,我只知道用户单击了Facebook.

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.

当然.用户可以在该其他应用程序中执行其所需的任何操作.用户不必按BACK.用户可能根本无法发送任何内容.那是在用户和该应用程序之间–您无法获得有关用户是否执行了任何操作,与谁共享信息的信息等等.

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.

这篇关于如何获取ACION_SEND意图的回调的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆