Кажется, что этот вопрос повсюду на SO, но ничего не работает. Я отправляю намерение с камеры Android в свое приложение (совместное использование изображения, сделанного с моей камерой Android, в мое приложение).Получить данные Exif от намерения ACTION_SEND (TAG_GPS_LATITUDE)
в моем 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 (нуль, imageUri.getPath()); распечатано /external/images/media/5670
Ошибка: E/JHEAD﹕ can't open '/external/images/media/5670'
, а затем Log.v(null, "lat "+str);
распечатывается lat null
?