【发布时间】:2023-03-10 00:00:01
【问题描述】:
似乎这个问题在 SO 上无处不在,但 什么都没有 在起作用。我正在从 Android 相机向我的应用发送意图(将使用我的 Android 相机拍摄的图像分享到我的应用)。
在我的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());打印出/external/images/media/5670
出现错误:E/JHEAD﹕ can't open '/external/images/media/5670' 然后Log.v(null, "lat "+str); 打印出lat null?
【问题讨论】: