android Intent.ACTION_SEND

时间:2023-03-08 23:33:31
android Intent.ACTION_SEND

ACTION_SEND intent 可以把自己的应用添加到系统的发送(分享)列表中。

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

接收和处理如下:

Intent intent = getIntent();
if (intent.getAction().equals(Intent.ACTION_SEND)) {
Bundle bundle = intent.getExtras();
if (bundle != null) {
Uri uri = (Uri) bundle.get(Intent.EXTRA_STREAM);
if (uri != null) {
try {
bitmap = MediaStore.Images.Media.getBitmap(this.getContentResolver(), uri);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}