如何在发送列表中添加我的Android应用程序?

bri*_*ian 5 android send

我实现了一个应用程序
它可以将照片上传到我自己的服务器.
我想让我的应用程序可以在代码下面的代码中列出发送列表:

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"));
Run Code Online (Sandbox Code Playgroud)

我该怎么做?

Vip*_*hah 8

您需要在清单中添加以下内容.

<intent-filter>
    <action android:name="android.intent.action.SEND"></action>
    <category android:name="android.intent.category.DEFAULT" />
    <data android:mimeType="image/jpeg" />
</intent-filter>
Run Code Online (Sandbox Code Playgroud)

你的清单应该看起来像跟随.

<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>
Run Code Online (Sandbox Code Playgroud)