通过意图共享位图并不能清除先前的位图

时间:2016-09-13 15:18:47

标签: android-intent bitmap share

点击我在intent中创建的分享按钮,尝试通过activity分享位图。第一次,它正确地共享位图,但如果我再次单击我的共享按钮并尝试共享另一个位图,它将共享先前的位图。

这里qrCodeFrame是我的FrameLayout,我正在动态地改变布局颜色,在chaning之后我创建了这个布局的位图,然后通过意图共享它。

private void share() {

    qrCodeFrame.setDrawingCacheEnabled(true);
    qrCodeFrame.buildDrawingCache();
    Bitmap bitap = qrCodeFrame.getDrawingCache();
    String pathofBmp = MediaStore.Images.Media.insertImage(getActivity().getContentResolver(), bitap, "QR code", "Scan this QR code");
    Uri bmpUri = Uri.parse(pathofBmp);
    final Intent emailIntent1 = new Intent(android.content.Intent.ACTION_SEND);
    emailIntent1.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    emailIntent1.putExtra(Intent.EXTRA_STREAM, bmpUri);
    emailIntent1.putExtra(Intent.EXTRA_SUBJECT, "Any Subject");
    emailIntent1.putExtra(Intent.EXTRA_TEXT, SharedPreference.getFacebookDataObtainedFromServer(getActivity()).getUserName() + " invites you to join.");
    emailIntent1.setType("image/png");
    startActivity(emailIntent1);
}

1 个答案:

答案 0 :(得分:0)

最后我得到了答案。

我正在改变布局并通过意图共享该布局的位图。这个过程我一次又一次地做,而不是使用以下两件事。

  

qrCodeFrame.invalidate();    qrCodeFrame.requestLayout();

所以很遗憾,我之前的布局位图并没有刷新布局。

相关问题