繁体   English   中英

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

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

我越来越烦人的错误:

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

当我尝试打开某些图像时会发生这种情况,当它发生时会退回到上一个活动。

而且我不知道是什么原因造成的。 仅当通过某些照片时才会发生。 但是我找不到它们之间的区别,因为我有几乎两个相同的图像,一个导致问题,而另一个则没有。 它们具有相同的分辨率685x960,大小为60KB。

编码:

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

压缩和解压缩方法:

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

并接收图像:

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

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

您将把位图保存到文件,仅发送文件名的路径,然后再次从路径读取。 是pos

暂无
暂无

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

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