【问题标题】:App not showing up in share menu应用程序未显示在共享菜单中
【发布时间】:2013-06-19 06:22:05
【问题描述】:

我将我的应用设置为通过这些意图过滤器和此处理程序接收共享意图。我在共享菜单中没有看到它。

<intent-filter>
    <action android:name="android.intent.action.SEND" />
    <category android:name="android.intent.category.DEFAULT" />
    <data android:scheme="http"/>
</intent-filter>
<intent-filter>
   <action android:name="android.intent.action.SEND" />
   <category android:name="android.intent.category.DEFAULT" />
   <data android:scheme="https"/>
</intent-filter>


Intent intent = getIntent();
String action = intent.getAction();
String type = intent.getType();
if (Intent.ACTION_SEND.equals(action) && type.equals("text/plain")) {
    AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
    builder.setTitle(R.string.pick_profile);
    builder.setItems(getConnProfNames(connectionProfiles), new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            selectedItem = connectionProfiles.get(which);
            DownloadTask.execute();
        }
    });
}

【问题讨论】:

  • 不存在共享意图。应用程序可以使用具有不同操作、类型、附加功能和数据的 Intent 共享数据。大多数这些应用程序将使用 ACTION_SEND,但根据应用程序的不同,其他参数会有很大差异。使用您的意图过滤器,您只能使用 http 和 https 方案捕获意图,并且您的代码确实将类型另外限制为 text/plain。这完全取决于“共享菜单”在触发时的作用,您的上述代码是否有效。
  • 具体来说,我正在尝试处理来自 Dolphin Browser 的共享链接意图。

标签: android android-intent share intentfilter


【解决方案1】:

没有共享意图这样的东西。应用程序可以使用具有不同操作、类型、附加功能和数据的 Intent 共享数据。大多数这些应用程序将使用 ACTION_SEND,但根据应用程序的不同,其他参数会有很大差异。使用您的意图过滤器,您只能使用 http 和 https 方案捕获意图,并且您的代码确实将类型另外限制为 text/plain。这完全取决于触发时“共享菜单”的作用,您的上述代码是否有效。

Dolphin 浏览器用于共享其数据的意图是 AFAIK,未公开记录。 我设法使用以下过滤器“捕捉”了它的一个意图:

<intent-filter>
   <action android:name="android.intent.action.SEND" />
   <data android:mimeType="*/*" />
   <category android:name="android.intent.category.DEFAULT" />
</intent-filter>

我还设法从附加内容中获取 URL,如下所示:

    CharSequence text = intent.getCharSequenceExtra(Intent.EXTRA_TEXT);

这实际上取决于您要实现什么过滤器。如果您尝试获取 URL 并加载 HTML 页面,那么我使用的过滤器将完成这项工作。它允许获取 URL,然后您可以显示页面,例如在 Web 视图中。

【讨论】:

    猜你喜欢
    • 2017-12-04
    • 2015-03-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-02
    • 1970-01-01
    相关资源
    最近更新 更多