All was going well developing a new app until I started dressing up the interface.
I have implemented the zxing barcode scanner within my project for user convenience and my custom control.
The only changes I make to the CaptureActivity are in handling the scan results. I also shot through the AndroidManifest.xml and took away the intent filters to avoid my app from being offered for the requests the barcode scanner app handles. (It doesn't feel right having the android OS offer my activity alongside of the hard earned "awesomeness" of Xzing's Barcode Scanner)
I added two ImageViews to my index activity and 1 of them triggers the scanner. The interesting part is that the image that shows up in the scanner is not the 1 that links to the scanner.
In summary, 2 images for navigation, Second Image leads to scanner, first image is blocking my scanner view.

At first I changed the name of the asset (was add_card.png to add_tag.png) and I had a clean view of the scanner, but since then the image has crept back in.
Here is some index activity code
//in on create ImageView view = (ImageView) findViewById(R.id.addTagButton); view.setOnClickListener(addCardListener); view = (ImageView) findViewById(R.id.scanButton); view.setOnClickListener(scanListener); // end of in on create private OnClickListener addCardListener = new OnClickListener() { public void onClick(View v) { startActivity(new Intent(getApplicationContext(), AddCard.class)); } }; private OnClickListener scanListener = new OnClickListener() { public void onClick(View v) { startActivity(new Intent(getApplicationContext(), CaptureActivity.class)); } };
Some xml that the index file loads
<ImageView android:src="@drawable/add_tag" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="6dip" android:layout_marginLeft="12dip" android:id="@+id/addTagButton" android:layout_gravity="bottom|left" ></ImageView>
And the only changes I made in the CaptureActivity are in the code that is triggered after reading the barcode.
UPDATE
I tried setting the launcher to CaptureActivity and the image is not showing up like in the screenshot. This was advice from Pawan and I think we were both hoping the problem would be replicated so that I would start looking in the 1 place I had already crossed off my list. (That is how I find my keys when they are lost)
UPDATE 2
I tried changing the ImageView in question (add_tag) to a button --- no change If I remove the ImageView in question from xml, not an applicable solution, the issue disappears. It is something about when that png is already loaded into memory. I have more images loaded than described above in my Index activity, but the add_tag image consistently shows up over the camera. Then if I keep the image resource in res/drawable
, but never load it into the Index activity, then it doesn't show up over the camera.
What are some reasons an image from the activity1 will end up in activity2? How can I clean up Index activity so that it is as if the xml never loaded the image in onStop?
UPDATE 3 I do not experience the problem anymore and can move on. I am still unsure if it has to do with the camera in general or Zxing. Considering Sean's advice about it having to do with Java.R, I tried removing the drawable that was causing the problem, rename, insert into project. This didn't exactly work.
It resolved when I added a copy of my drawable into the project.
The drawable folder now starts with add_card add_tag ...etc
If I set my ImageView to add_card in the Index activity, the problem occurs, If I set my ImageView to add_tag no problem occurs. --> This leads me to believe that the first (alphabetically) drawable resource will conflict with Scanner I am going to keep a placeholder image that I never load as the top of the drawable folder and keep my fingers crossed.
There's some food for thought. (I am still open to someone explaining to me why this is happening)
PS Feel free to edit down my question if you feel my journey to the solution is a little bloated.