当用户共享图像并按取消时,createchooser会继续使用上次呼叫中的信息,即使我进行新共享时,仍会存储在那里的旧信息。
用户取消共享时如何重置意图数据?
我正在使用此代码进行共享
private void shareIt() {
uri = Uri.fromFile(imagePath);
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
sharingIntent.setType("image/*");
String shareBody = "try this app";
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "social share app");
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareBody);
sharingIntent.putExtra(Intent.EXTRA_STREAM, uri);
startActivity(Intent.createChooser(sharingIntent, "share by .."));
}
最佳答案
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
Uri screenshotUri = Uri.parse(path);
sharingIntent.setType("image/*");
sharingIntent.putExtra(Intent.EXTRA_STREAM, screenshotUri);
startActivity(Intent.createChooser(sharingIntent, "Share image using"));
使用bove代码
将此代码显示出来
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>