简体   繁体   English

传递byte []时,Android返回上一个活动

[英]Android backs to previous activity when passing byte[]

I am getting hell annoying error: 我越来越烦人的错误:

12-12 03:46:48.241 23461-23461/com.cronline.haito.projectbeggining W/EGL_genymotion: eglSurfaceAttrib not implemented
12-12 03:46:48.241 23461-23461/com.cronline.haito.projectbeggining E/OpenGLRenderer: Getting MAX_TEXTURE_SIZE from GradienCache
12-12 03:46:48.245 23461-23461/com.cronline.haito.projectbeggining E/OpenGLRenderer: Getting MAX_TEXTURE_SIZE from Caches::initConstraints()
12-12 03:46:48.245 23461-23461/com.cronline.haito.projectbeggining D/OpenGLRenderer: Enabling debug mode 0

It happens when i try to open certain images and when it happens it backs of to the previous activity. 当我尝试打开某些图像时会发生这种情况,当它发生时会退回到上一个活动。

And I have no idea whatsoever what is causing it. 而且我不知道是什么原因造成的。 It happens only when passing some of the photos. 仅当通过某些照片时才会发生。 But i can't find difference between them, because I have almost 2 same image, one cause problems and other don't. 但是我找不到它们之间的区别,因为我有几乎两个相同的图像,一个导致问题,而另一个则没有。 They have same resolution 685x960 and size of 60KB. 它们具有相同的分辨率685x960,大小为60KB。

The code: 编码:

Passing to the second activity
Intent intent = new Intent(getActivity(), EditorActivity.class);
intent.putExtra("image", BitmapTransformer.compress(bitmap));
startActivity(intent);

Compress and decompress methods: 压缩和解压缩方法:

public static byte[] compress(Bitmap bmp){
        ByteArrayOutputStream stream = new ByteArrayOutputStream();
        bmp.compress(Bitmap.CompressFormat.PNG, 80, stream);
        return stream.toByteArray();
    }
public static Bitmap decompress(byte[] data){
    return BitmapFactory.decodeByteArray(data, 0, data.length);
}

And receiving an image: 并接收图像:

Intent intent = getIntent();
byte[] imageAsByteArray = intent.getExtras().getByteArray("image");
Bitmap bitmap = BitmapTransformer.decompress(imageAsByteArray);

Images causing problems: https://www.dropbox.com/sh/ylwhbpdx41w6x2u/AAAUtQsYppge5kb7dEBHuouHa?dl=0 图片导致问题: https//www.dropbox.com/sh/ylwhbpdx41w6x2u/AAAUtQsYppge5kb7dEBHuouHa?dl = 0

You are to save your Bitmap to file and send only path of file name, and then read from path again. 您将把位图保存到文件,仅发送文件名的路径,然后再次从路径读取。 It is pos 是pos

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM