public Uri getImageUri(Context inContext, Bitmap inImage) {
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
inImage.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
String path = Images.Media.insertImage(inContext.getContentResolver(), inImage, String.valueOf(System.currentTimeMillis()), null);
return Uri.parse(path);
}
这是我的代码 我有时会得到这个例外。这是因为DCIM /存储文件夹 我怎么能避免这个问题 这是我的代码 我有时会得到这个例外。这是因为DCIM /存储文件夹 我怎么能避免这个问题 这是我的代码 我有时会得到这个例外。这是因为DCIM /存储文件夹 我该如何避免这个问题
java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=-1, data=Intent { dat=content://media/external/images/media/30971 flg=0x1 }} to activity {com.mobisys.biod.questabird/com.mobisys.biod.questagame.SightingActivity}: java.lang.NullPointerException: uriString
at android.app.ActivityThread.deliverResults(ActivityThread.java:3700)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:3743)
at android.app.ActivityThread.access$1400(ActivityThread.java:172)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1356)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5653)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException: uriString
at android.net.Uri$StringUri.<init>(Uri.java:468)
at android.net.Uri$StringUri.<init>(Uri.java:458)
at android.net.Uri.parse(Uri.java:430)
at com.mobisys.biod.questagame.SightingActivity.getImageUri(SightingActivity.java:620)
at com.mobisys.biod.questagame.SightingActivity.onActivityResult(SightingActivity.java:944)
at android.app.Activity.dispatchActivityResult(Activity.java:5732)
at android.app.ActivityThread.deliverResults(ActivityThread.java:3696)
... 11 more