Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/193.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将自定义操作添加到Android共享表_Android_Android Intent_Android Sharing - Fatal编程技术网

将自定义操作添加到Android共享表

将自定义操作添加到Android共享表,android,android-intent,android-sharing,Android,Android Intent,Android Sharing,我有一个应用程序,用户应该能够共享一些文本。现在我想提供Android提供的默认纯文本共享选项。我使用以下代码执行此操作: Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND); sendIntent.putExtra(Intent.EXTRA_TEXT, text); sendIntent.setType("text/plain"); Intent chooser = Intent.createC

我有一个应用程序,用户应该能够共享一些文本。现在我想提供Android提供的默认纯文本共享选项。我使用以下代码执行此操作:

Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, text);
sendIntent.setType("text/plain");

Intent chooser = Intent.createChooser(sendIntent, "Share");
startActivity(chooser);
这看起来有点像:

资料来源:

但现在,我还希望能够在共享服务选择器对话框中增加一个选项,在我自己的代码中触发自定义操作。也就是说,我希望用户能够喜欢一个条目。因此,除了通过短信、电子邮件、FB等方式分享外,我希望在列表的顶部还有一个条目,上面写着“添加到收藏夹”(如果可能的话,包括一个图标)

所以我的问题是这是否可能?!?如果,如何:)

任何提示都将不胜感激

意图过滤器通知系统应用程序组件愿意接受的意图。类似于您在“向其他应用发送简单数据”课程中使用action_SEND构建意图,您创建意图过滤器是为了能够通过此操作接收意图。您可以使用元素在清单中定义一个意图过滤器。例如,如果您的应用程序处理接收文本内容、任何类型的单个图像或任何类型的多个图像,则清单如下所示:


可以,但是每个应用程序都可以使用这个动作吗?但我更喜欢只添加一个与我的应用程序相关的操作。。。我不能在采摘器里夸大一些动作之类的?!?
<activity android:name=".ui.MyActivity" >
    <intent-filter>
        <action android:name="android.intent.action.SEND" />
        <category android:name="android.intent.category.DEFAULT" />
        <data android:mimeType="image/*" />
    </intent-filter>
    <intent-filter>
        <action android:name="android.intent.action.SEND" />
        <category android:name="android.intent.category.DEFAULT" />
        <data android:mimeType="text/plain" />
    </intent-filter>
    <intent-filter>
        <action android:name="android.intent.action.SEND_MULTIPLE" />
        <category android:name="android.intent.category.DEFAULT" />
        <data android:mimeType="image/*" />
    </intent-filter>
</activity>