开发者

MIME types and ACTION_SEND intent chooser

开发者 https://www.devze.com 2023-01-29 13:48 出处:网络
I\'m using very standard code to send images from my app.A user emailed me that their default messaging app doesn\'t show up in the chooser, and oddly enough the same happens on my phone.I was playing

I'm using very standard code to send images from my app. A user emailed me that their default messaging app doesn't show up in the chooser, and oddly enough the same happens on my phone. I was playing around with the MIME type of the intent. "text/plain" shows a set of options including my Messages app, and "*/*" shows a ton. Would I be lazy to set the MIME type to "*/*" so that I don't get filtered by apps that should be an option for the user to send images? Or is that pretty much the way to go?

        Intent intent = new Intent(Intent.ACTION_SEND);
        intent.setType("image/jpeg");
        Uri uri = Uri.fromFile(file);
        intent.putE开发者_JAVA百科xtra(Intent.EXTRA_STREAM, uri);
        activity.startActivity(Intent.createChooser(intent, "Custom Heading..."));

One side effect of this that I don't like is that a few apps (Facebook, Handcent) have multiple intents registered to send various MIME types, so they show up in the list more than once when the MIME type is "*/*".


The built in messaging should handle your mime type, so it may be a platform specific issue:

       <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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号