It seems like this question is everywhere on SO but nothing is working. I am sending an intent from the Android camera to my app (sharing a image taken with my Android camera to my app).
in my framgent
:
// ...
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = null;
Intent intent = getActivity().getIntent();
String action = intent.getAction();
String type = intent.getType();
if (Intent.ACTION_SEND.equals(action) && type != null) {
if ("text/plain".equals(type)) {
// ...
} else if (type.startsWith("image/")) {
Uri imageUri = (Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM);
if (imageUri != null) {
Log.v(null, imageUri.getPath());
try {
ExifInterface exif = new ExifInterface(imageUri.getPath());
String str = exif.getAttribute(ExifInterface.TAG_GPS_LATITUDE);
Log.v(null, "lat "+str);
} catch (IOException e) {
e.printStackTrace();
}
// ...
}
}
} else {
view = inflater.inflate(R.layout.fragment_main, container, false);
initComponents(view);
initListeners();
}
return view;
}
// ...
Log.v(null, imageUri.getPath()); prints out /external/images/media/5670
The error appears: E/JHEAD﹕ can't open '/external/images/media/5670'
and then Log.v(null, "lat "+str);
prints out lat null
?