【发布时间】: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