I am trying to select and image from gallery and print its path along with gps tags using ExifInterface. I am using nexus 4 (kitkat 4.4.2) for debugging and the path to the image I get is
/ storage / emulate / 0 / DCIM / image_file_name but ExifInterface returns null for all tags, and logcat shows a JHEAD error cant open '/ storage / emulated / 0 / DCIM / image_file_name' (application does not crash). Please, help.
Main activity code:
package com.example.images; import java.io.File; import java.io.IOException; import android.media.ExifInterface; import android.net.Uri; import android.os.Bundle; import android.provider.MediaStore; import android.annotation.SuppressLint; import android.app.Activity; import android.content.Intent; import android.database.Cursor; import android.view.Menu; import android.view.View; import android.widget.Button; import android.widget.ImageView; import android.widget.RelativeLayout; import android.widget.TextView; import android.widget.Toast; public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Button button = (Button) findViewById(R.id.button1); button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) {
Log Code:
02-18 19:59:04.267: D/dalvikvm(9815): Late-enabling CheckJNI 02-18 19:59:04.287: D/dalvikvm(9815): Debugger has detached; object registry had 1 entries 02-18 19:59:04.538: D/OpenGLRenderer(9815): Enabling debug mode 0 02-18 19:59:11.905: D/dalvikvm(9815): GC_FOR_ALLOC freed 96K, 2% free 9147K/9280K, paused 15ms, total 16ms 02-18 19:59:11.946: I/dalvikvm-heap(9815): Grow heap (frag case) to 39.442MB for 31961104-byte allocation 02-18 19:59:11.956: D/dalvikvm(9815): GC_FOR_ALLOC freed 3K, 1% free 40356K/40496K, paused 13ms, total 13ms 02-18 19:59:12.306: E/JHEAD(9815): can't open '/storage/emulated/0/DCIM/Camera/IMG_20140217_210408.jpg'
Manifest file:
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.images" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="9" android:targetSdkVersion="14" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name="com.example.images.MainActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest>
source share