【问题标题】:share Fb,Tw and Email using Intent.action_SEND in android在 android 中使用 Intent.action_SEND 分享 Fb、Tw 和电子邮件
【发布时间】:2013-04-22 06:50:38
【问题描述】:

我必须将文本和电子邮件发布到 FB、TW 和电子邮件。

这里我创建了一个图像视图。如果我必须单击这些图像视图,则表示警报对话框正在打开。这里列出了以下 3 项:FB、TW、Email

如果我必须在警报列表中使用 FB,这意味着它是使用 action_send 转到 FB 应用程序...同时发布文本和图像。其他 TW 和电子邮件应用程序是隐藏的。

如果我点击警报列表上的 TW 意味着它是转到 Tw 应用程序并同时发布文本和图像隐藏 FB、电子邮件应用程序...

我该怎么办???

请帮助我..我使用了下面的代码...在这里我点击 Fb 意味着什么也没发生???请给我这些解决方案...我的设备也安装了 FB,TW 应用程序...那为什么什么都没有发生???请给我建议???我的代码有什么问题???

ImageView share = (ImageView) findViewById(R.id.imageView5);
    share.setOnClickListener(new OnClickListener()
    {
        public void onClick (  final View v )
        {
            final CharSequence[] items =
            {
                    "Facebook", "Twitter", "Email"
            };

            AlertDialog.Builder builder = new AlertDialog.Builder(SubCate.this);
            builder.setTitle("Share Via:");
            builder.setItems(items, new DialogInterface.OnClickListener()
            {
                public void onClick ( DialogInterface dialog , int item )
                {
                    if (items[item] == "Facebook")
                    {

                        initShareIntent("facebook");

                    }
                    if(items[item] == "Twitter"){
                        initShareIntent("twitter");

                       } 
                    if (items[item] == "Email")
                    {

                        initShareIntent("gmail");

                    }
                }
            });
            AlertDialog alert = builder.create();
            alert.show();
        }
    });
}



  private void initShareIntent(String type) {
        boolean found = false;
        Intent share = new Intent(android.content.Intent.ACTION_SEND);
        share.setType("image/jpeg");

        // gets the list of intents that can be loaded.
        List<ResolveInfo> resInfo = getPackageManager().queryIntentActivities(share, 0);
        if (!resInfo.isEmpty()){
            for (ResolveInfo info : resInfo) {
                if (info.activityInfo.packageName.toLowerCase().contains(type) || 
                        info.activityInfo.name.toLowerCase().contains(type) ) {
                    share.putExtra(Intent.EXTRA_SUBJECT,  _Substring);
                    share.putExtra(Intent.EXTRA_TEXT,     _Substring);
                    share.putExtra(Intent.EXTRA_STREAM, Uri.parse(_Image)); 
                    share.setPackage(info.activityInfo.packageName);
                    found = true;
                    break;
                }
            }
            if (!found)
                return;

            startActivity(Intent.createChooser(share, "Select"));
        }
    }

编辑:

在这里我必须运行应用程序:

如果我必须点击 Fb 意味着 Facebook 墙正在打开...但是这里没有显示文字...

如果我点击 Tw 意味着推特墙正在打开...推特文字显示在墙上..但图像无法加载消息显示 ....

如果我必须点击电子邮件,则表示 gmail 正在打开并且还很好地显示了主题上的文字...

为什么 twiiter image could not load 消息正在显示...而且 FB 文本和图像也没有显示 ????请给我解决这些????

【问题讨论】:

    标签: android facebook android-intent android-alertdialog intentfilter


    【解决方案1】:

    将 SoicalAuth 用于此功能非常简单,您无需为此创建列表视图和布局.... 见this link

    【讨论】:

    • 是的,我已经这样做了..我希望通过 action_send 来开发 ..这就是我发布的
    • 好的。我有一个建议,如果您有要在 fb、twitter 等上发布的列表,那么为什么您需要按钮并点击事件。您希望以这种方式开发。
    【解决方案2】:

    在 facebook 中,它的已知问题是用户无法通过操作发送加载文本,但您可以上传图像。您还可以使用 facebook api 加载文本。

    在 twitter 中,您也可以发送图像和文本,它不会显示任何问题。

    试试下面的代码。希望这会帮助你 。

    Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
    
                shareIntent.setType("image/*");
    
                shareIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
    
                Uri uri = Uri.parse("file://"+combinedFilepath.trim());
                    String extraString="set";
                    shareIntent.putExtra(Intent.EXTRA_TEXT,extraString);                                    
                    shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
                    shareIntent.putExtra(Intent.EXTRA_TITLE, extraString);
                    shareIntent.putExtra(Intent.EXTRA_SUBJECT, "app name");         
    
                    startActivity(Intent.createChooser(shareIntent, "Share via"));
    

    【讨论】:

    • 我只想上传这些图片:dev2.mercuryminds.com/website/var/tmp/… 是可能的......
    • 我没有得到任何图像。它说找不到 404 文件
    • action send 将只接受从外部内存上传的图像。它不会从内部存储器或 weburl 接受它。首先,您需要将其保存在 sdcard 中,然后您可以将其删除。如果你不想更进一步。
    • 哦,好吧..fb墙在这里打开。但测试没有显示在facebook墙上..我的代码有什么问题
    • 你的意思是文字?我们无法使用操作发送将文本发送到 Facebook 墙
    猜你喜欢
    • 2011-06-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-09
    • 1970-01-01
    • 2016-01-23
    • 1970-01-01
    相关资源
    最近更新 更多