自定义应用选择器对话框

时间:2017-08-08 09:05:54

标签: android android-intent

我正在开发一个共享应用,我可以在其中分享来自Gallery / GooglePhotos等其他应用的任何图像文件。 这个我可以通过

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

当用户点击要共享的图片时,应用选择器对话框会显示可以共享的所有相关应用(包括我的应用)。 这可以在该对话框上添加消息,建议用户使用我的应用程序吗?

2 个答案:

答案 0 :(得分:0)

您可以尝试以下代码;

Intent sharingIntent = new Intent(Intent.ACTION_SEND);
Uri screenshotUri = Uri.parse(image_path);
sharingIntent.setType("image/png");
sharingIntent.putExtra(Intent.EXTRA_STREAM, screenshotUri);
startActivity(Intent.createChooser(sharingIntent, "Share image using"));

答案 1 :(得分:0)

因此,如果我理解您的问题,您需要在其他第三方应用程序打开的选择器上设置标题。这是不可能的,因为它取决于那些其他第三方应用程序来设置标题,而不是你的。想象一下,如果像你这样拥有共享功能的应用程序想要设置不同的标题,会发生什么呢?