【问题标题】:Share intent is showing only messaging & bluetooth app. How can I have more options/apps to share with?共享意图仅显示消息和蓝牙应用。我怎样才能有更多的选项/应用程序来分享?
【发布时间】:2015-11-20 15:12:20
【问题描述】:

我想在我的应用中添加分享功能。

我想分享指向我的应用的链接。

这是我到目前为止所做的:

LinearLayout linearLayoutShareAppContainer = (LinearLayout) findViewById(R.id.share_app_container);
        linearLayoutShareAppContainer.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                final Handler handler3 = new Handler();
                handler3.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        Intent sharingIntent = new Intent(Intent.ACTION_SEND);
                        sharingIntent.setType("text/plain");
                        String shareBody = "Here is the share content body";
                        sharingIntent.putExtra(Intent.EXTRA_TEXT, shareBody);
                        startActivity(Intent.createChooser(sharingIntent, "Share via..."));
                    }
                }, 200);
            }
        });

问题在于,点击分享文本(布局)时,只会显示蓝牙和消息应用分享。

我想要有更多的应用程序,如 WhatsApp、Facebook、Twitter 等来分享。

因为我是初学者,我不知道该怎么做!

请告知。

谢谢。

【问题讨论】:

  • 如果设备上安装了 WhatsApp、Facebook 和 Twitter 等应用程序,您拥有的代码将显示这些应用程序。
  • @Suhas 他们已经安装了,但他们没有出现!!
  • 您的设备中是否安装了 Facebook、Twitter、环聊等应用程序......!!因为,Intent.ACTION_SEND 会选择您设备中安装的相关应用。

标签: java android android-intent android-sharing


【解决方案1】:

与我在这里遇到的问题相同: Android: chooser dialog skipped while sharing text type data to external app

  1. 要么您的设备中没有其他合适的应用,要么
  2. 您必须清除/恢复您的默认应用设置(例如,电话设置> 管理应用>重置应用首选项)

【讨论】:

  • 我解决了这个问题,现在的问题是,假设您选择 WhatsApp 来共享,然后当您单击联系人时……所有内容都消失了,我的应用程序再次启动,没有共享任何内容。
  • “全部消失”是什么意思?这可能涉及代码/设备中更多可能的原因,请尝试打开一个新主题并发布您的代码以讨论它或先进行代码调试
  • 我的意思是说,点击联系人后,什么都没有分享,我又回到了我的应用程序。
  • 我试过你上面的代码,分享内容没有问题
  • 不知道为什么会出现这个问题!!
【解决方案2】:

你可以使用

startActivity(Intent.createChooser(sendIntent, "choose one"));

【讨论】:

    猜你喜欢
    • 2013-05-21
    • 1970-01-01
    • 1970-01-01
    • 2012-02-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-23
    相关资源
    最近更新 更多