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

时间:2012-11-28 02:38:45

标签: 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"));

我该怎么办?

1 个答案:

答案 0 :(得分: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>

你的清单看起来应该跟随。

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