I’m having trouble showing the current image that I have captured using a 3rd party android application and showing it on my own native app. It’s always an empty screen with just the action bar. However, the photo taken could be located in the folder i have specified.
Could someone kindly assist? Greatly appreciated! Cheers 🙂
XML File:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:id="@+id/linear">
<ImageView android:id="@+id/imageView1"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:contentDescription="@string/desc"/>
</LinearLayout>
Source Code:
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch(requestCode) {
case 0:
if(resultCode == Activity.RESULT_OK){
Bitmap photo = (Bitmap) data.getExtras().get("data");
imageView.setImageBitmap(photo);
}
break;
case 1:
if(resultCode == RESULT_OK){
Uri selectedImage = data.getData();
imageView.setImageURI(selectedImage);
}
break;
}
}
}
add above line to your xml of the ImageView where desc should be in string.xml and set it to something.
Looks like this defines text that briefly describes content of the view. This property is used primarily for accessibility. Since some views do not have textual representation this attribute can be used for providing such.
Non-textual widgets like ImageViews and ImageButtons should use the contentDescription attribute to specify a textual description of the widget such that screen readers and other accessibility tools can adequately describe the user interface.
use the above code