MIME类型和ACTION_SEND意图选择器

时间:2010-12-06 05:24:44

标签: android android-intent

我正在使用非常标准的代码从我的应用程序发送图像。一位用户通过电子邮件告诉我,他们的默认消息传递应用程序没有显示在选择器中,奇怪的是,我的手机上也是如此。我正在玩意图的MIME类型。 "text/plain"显示了一组选项,包括我的消息应用,"*/*"显示了一个吨。我是否会懒惰地将MIME类型设置为"*/*",这样我就不会被应用程序过滤,应该是用户发送图像的选项?或者这是几乎要走的路?

        Intent intent = new Intent(Intent.ACTION_SEND);
        intent.setType("image/jpeg");
        Uri uri = Uri.fromFile(file);
        intent.putExtra(Intent.EXTRA_STREAM, uri);
        activity.startActivity(Intent.createChooser(intent, "Custom Heading..."));

我不喜欢的一个副作用是,一些应用程序(Facebook,Handcent)注册了多个意图发送各种MIME类型,因此当MIME类型为{时,它们会多次出现在列表中{1}}。

1 个答案:

答案 0 :(得分:4)

内置消息传递应该处理你的mime类型,因此它可能是特定于平台的问题:

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

Check out the source for all the mime types that are handled

相关问题