【问题标题】:Sharing bitmap through intent doesn't clear previous bitmap通过意图共享位图不会清除以前的位图
【发布时间】:2016-09-13 15:18:47
【问题描述】:

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

这里 qrCodeFrame 是我的 FrameLayout,我正在动态更改布局颜色,并且在更改后我正在创建此布局的位图,然后通过意图共享它。

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);
}

【问题讨论】:

  • 你能放一些代码给我们看看吗?

标签: android-intent bitmap share


【解决方案1】:

我终于得到了答案。

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

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

所以不幸的是,我正在制作先前布局的位图而不是刷新布局的位图。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-04-12
    • 2012-02-21
    • 1970-01-01
    • 2016-01-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多