2010-12-06 98 views
2

我使用非常标准的代码从我的应用程序发送图像。用户给我发电子邮件说他们的默认消息应用程序没有显示在选择器中,奇怪的是我的手机也发生了同样的情况。我正在玩弄意图的MIME类型。 "text/plain"显示了一组选项,包括我的Messages应用程序,并且"*/*"显示了一吨。我是否懒得将MIME类型设置为"*/*",这样我就不会被应用程序过滤,这些应用程序应该是用户发送图像的选项?或者,这几乎是要走的路?这是我不喜欢MIME类型和ACTION_SEND意向选择器

 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...")); 

一个副作用是,一些应用程序(脸谱,Handcent)已经注册了多个意图发送各种MIME类型,所以他们出现在列表中不止一次当MIME类型是"*/*"

回答

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