How to add my Android app show in send list?

血红的双手。 提交于 2019-12-05 00:37:15

问题


I implement an app.
It can upload photos to my own server.
I want to let my app can list in send list when implement below code:

Intent share = new Intent(Intent.ACTION_SEND);
share.setType("image/jpeg");
share.putExtra(Intent.EXTRA_STREAM, Uri.parse(FilePath));
startActivity(Intent.createChooser(share, "Share Image"));

How can I do it?


回答1:


You need to add following in your manifest.

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

Your manifest should look something like follow.

<application android:name="MyApplication" android:allowBackup="true" android:icon="@drawable/ic_launcher"
android:label="@string/app_name" android:theme="@style/AppTheme">
    <activity android:name="com.example.arcasample.MainActivity" android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.SEND"></action>
            <category android:name="android.intent.category.DEFAULT" />
            <data android:mimeType="image/jpeg" />
        </intent-filter>
    </activity>
</application>


来源:https://stackoverflow.com/questions/13596882/how-to-add-my-android-app-show-in-send-list

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!