Create own camera as I'need Focus ON for taking picture. Camera works perfectly fine as expected. Passing URI
between activities.
I've ImageView in Next Screen which i used to set the Image with
imgView.setImageURI(absPathUri);
Checked that absPathUri
is not null. Still ImagView is blank with no pictures. Doing the same in debug mode brings the Picture in ImageView.
Can anybody please tell where I'm doing wrong?
Also send broadcast to re-scan the device but still no success with following snippet.
Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
File f = new File(absPathUri.getPath());
Uri contentUri = Uri.fromFile(f);
mediaScanIntent.setData(contentUri);
this.sendBroadcast(mediaScanIntent);
Uses Below snippet to generate absPathUri
if (Environment.MEDIA_MOUNTED.equals(state))
{
imageDirectory = new File(AppConstants.IMAGE_DIRECTORY_PATH);
}
else
{
imageDirectory = new File(AppConstants.IMAGE_DIRECTORY_PATH_DATA);
}
imageDirectory.mkdirs();
File tempFile = new File(imageDirectory, getVideoName()+ jpg);
Uri outputFileUri = Uri.fromFile( tempFile );
absPathUri = outputFileUri;
public static String getVideoName()
{
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
try {
name = sdf.format(new Date(System.currentTimeMillis()));
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return name;
}
Below is the Layout which i used to show the ImageView in xml.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@drawable/bg"
>
<ImageView
android:id="@+id/picView"
android:layout_above="@+id/buttonPanel"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="center"
android:src="@drawable/accounts_glyph_password_default"
/>
<LinearLayout
android:id="@id/buttonPanel"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="horizontal"
>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:onClick="onDiscard"
/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
android:text="@string/save"
android:onClick="onSave"
android:textColor="#ffffff" />
</LinearLayout>
</RelativeLayout>