意图似乎不活动之间发送 [英] Intent seems not sent between activity

查看:121
本文介绍了意图似乎不活动之间发送的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经写了一个应用程序有2个活动。一个活动拍了一张照片,并与一些过滤器第二个使用它。

I have wrote an app with 2 activities. One activity took a picture and the second one use it with some filters.

活动1:

Intent FilterSelectionIntent = new Intent(getActivity(), PulsFiltersActivity.class);
FilterSelectionIntent.putExtra("PicTaken", currentBitmap);
startActivity(FilterSelectionIntent);

2活性的研究:

Acitivity 2:

    Bundle bd = intent.getExtras();
    mBitmap = bd.getParcelable("PicTaken");

我已经把一些断点在活动2,它从来不停止。当我评论了putExtra的评论,我能达到的断点。在我的情况下,该活动还没开始,我认为其目的是错误的。

I have put some breakpoints in the Activity 2 and it never stop at. As soon as I comment the "putExtra" in comment, I can reach the breakpoints. In my case, the activity is not started, I think the intent is wrong.

我知道有解决方案是使用Bitmap.com preSS和输出流中转发的结果。但对我来说,它花太多时间。我的Andr​​oid设备是一个非常基本的一个,它需要2秒保存BMP。这就是为什么我尝试使用意图传递说法,但似乎不工作。

I know that one solution is to use Bitmap.compress and forward the result in the Output stream. but in my case, it take too much time. My android device is a very basic one and it takes 2s to save the bmp. this why I try to use the intent to pass argument but it seems not working.

我也开到BMP保存为tmp文件,但我可能会失去2秒。

I'm also open to save the bmp as tmp file but I can lose 2 sec.

任何想法。

推荐答案

位图实现Parcelable,所以你总是可以通过它的意图:

Bitmap implements Parcelable, so you could always pass it in the intent:

Intent intent = new Intent(this, NextActivity.class);
intent.putExtra("BitmapImg", bitmap);

和检索它在另一端

Intent intent = getIntent();
Bitmap bitmap = (Bitmap) intent.getParcelableExtra("BitmapImg");

检查在这里:<一href=\"http://stackoverflow.com/questions/2459524/how-can-i-pass-a-bitmap-object-from-one-activity-to-another\">How我可以通过一个位图对象从一个活动到另一个

这篇关于意图似乎不活动之间发送的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆