Android. Why would an image in activity 1 end up in activity 2? (Zxing CaptureActivity is activity 2)

若如初见. 提交于 2019-12-06 14:13:00

The most likely explanation is that your generated R.java file is out of sync with your compiled code.

It's possible that your bytecode refers to constant values that have since changed, and so are now pointing at the wrong images. Just clean and recompile, if so. But I don't think that's it.

I think you've got resource IDs from our code, and yours, and it's not using the one you think. This is symptomatic of copying-and-pasting our project. We strongly discourage starting from a clone; there are far too many of those already. It would be better (and probably less error prone) to write your own scanner app and reuse bits and pieces as needed.

The bug is manifesting itself only when xzing's CaptureActivity is "called" from activity that is in landscape mode. If "calling" activity is in portait bug does not occur. Subsequent calls to CaptureActivity are OK from landscape mode. I can't find the exact cause but the effect is that Views in CaptureActivity "autoset" drawable for background and thus obstructing the camera view. Luckily there are two possible workarounds: 1. As Maudicus found himself: just place some image file in res/drawable/ that is first alphabetically, for example aaa.png. 2. Remove background drawables at runtime like this:

((TextView) findViewById(R.id.status_view)).setBackgroundDrawable(null);
((ViewfinderView) findViewById(R.id.viewfinder_view)).setBackgroundDrawable(null);

Place the code in onCreate() just bellow setContentView(R.layout.capture);.

You may need to remove background drawables from more views depending on what is visible in your layout.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!