gpt4 book ai didi

android - java.lang.RuntimeException : Unable to resume activity on Lg series 错误

转载 作者:行者123 更新时间:2023-11-29 17:57:52 28 4
gpt4 key购买 nike

当我拍照时,我收到以下错误消息。请注意,该应用程序可在 HTC rhyme 和 galaxy tab 7.7 上完美运行。如何修复?

    08-06 13:18:29.084: E/AndroidRuntime(27803): FATAL EXCEPTION: main
08-06 13:18:29.084: E/AndroidRuntime(27803): java.lang.RuntimeException: Unable to resume activity {ua.mirkvartir.android.frontend/ua.mirkvartir.android.frontend.AddFillActivityApp}: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=12, result=-1, data=null} to activity {ua.mirkvartir.android.frontend/ua.mirkvartir.android.frontend.AddFillActivityApp}: java.lang.NullPointerException
08-06 13:18:29.084: E/AndroidRuntime(27803): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2608)
08-06 13:18:29.084: E/AndroidRuntime(27803): at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2636)
08-06 13:18:29.084: E/AndroidRuntime(27803): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2103)
08-06 13:18:29.084: E/AndroidRuntime(27803): at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3576)
08-06 13:18:29.084: E/AndroidRuntime(27803): at android.app.ActivityThread.access$700(ActivityThread.java:138)
08-06 13:18:29.084: E/AndroidRuntime(27803): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1210)
08-06 13:18:29.084: E/AndroidRuntime(27803): at android.os.Handler.dispatchMessage(Handler.java:99)
08-06 13:18:29.084: E/AndroidRuntime(27803): at android.os.Looper.loop(Looper.java:137)
08-06 13:18:29.084: E/AndroidRuntime(27803): at android.app.ActivityThread.main(ActivityThread.java:4905)
08-06 13:18:29.084: E/AndroidRuntime(27803): at java.lang.reflect.Method.invokeNative(Native Method)
08-06 13:18:29.084: E/AndroidRuntime(27803): at java.lang.reflect.Method.invoke(Method.java:511)
08-06 13:18:29.084: E/AndroidRuntime(27803): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
08-06 13:18:29.084: E/AndroidRuntime(27803): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
08-06 13:18:29.084: E/AndroidRuntime(27803): at dalvik.system.NativeStart.main(Native Method)
08-06 13:18:29.084: E/AndroidRuntime(27803): Caused by: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=12, result=-1, data=null} to activity {ua.mirkvartir.android.frontend/ua.mirkvartir.android.frontend.AddFillActivityApp}: java.lang.NullPointerException
08-06 13:18:29.084: E/AndroidRuntime(27803): at android.app.ActivityThread.deliverResults(ActivityThread.java:3205)
08-06 13:18:29.084: E/AndroidRuntime(27803): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2595)
08-06 13:18:29.084: E/AndroidRuntime(27803): ... 13 more
08-06 13:18:29.084: E/AndroidRuntime(27803): Caused by: java.lang.NullPointerException
08-06 13:18:29.084: E/AndroidRuntime(27803): at android.content.ContentResolver.acquireUnstableProvider(ContentResolver.java:1094)
08-06 13:18:29.084: E/AndroidRuntime(27803): at android.content.ContentResolver.query(ContentResolver.java:354)
08-06 13:18:29.084: E/AndroidRuntime(27803): at android.content.ContentResolver.query(ContentResolver.java:313)
08-06 13:18:29.084: E/AndroidRuntime(27803): at android.support.v4.content.CursorLoader.loadInBackground(CursorLoader.java:49)
08-06 13:18:29.084: E/AndroidRuntime(27803): at ua.mirkvartir.android.frontend.AddFillActivityApp.getRealPathFromURI(AddFillActivityApp.java:844)
08-06 13:18:29.084: E/AndroidRuntime(27803): at ua.mirkvartir.android.frontend.AddFillActivityApp.onActivityResult(AddFillActivityApp.java:704)
08-06 13:18:29.084: E/AndroidRuntime(27803): at android.app.Activity.dispatchActivityResult(Activity.java:5492)
08-06 13:18:29.084: E/AndroidRuntime(27803): at android.app.ActivityThread.deliverResults(ActivityThread.java:3201)

对于结果调用

Calendar c = Calendar.getInstance();
ContentValues values = new ContentValues();
values.put(MediaStore.Images.Media.TITLE,
"zdanie " + c.getTime());
mCapturedImageURI = getContentResolver()
.insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
values);
Intent intentPicture = new Intent(
MediaStore.ACTION_IMAGE_CAPTURE);
intentPicture.putExtra(MediaStore.EXTRA_OUTPUT,
mCapturedImageURI);
startActivityForResult(intentPicture, 12);

结果

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 12 && resultCode == RESULT_OK) {
// photo1 = getRealPathFromURI(mCapturedImageURI);
saveFile(
decodeSampledBitmapFromResource(
getRealPathFromURI(mCapturedImageURI), 800, 800), 1);
pho1.setImageBitmap(decodeSampledBitmapFromResource(
getRealPathFromURI(mCapturedImageURI), 80, 60));
miss1 = 1;

}
}

获取真实路径

   public String getRealPathFromURI(Uri contentUri) {
if (contentUri==null){
Log.e("RealPath", "URI: null");
}else Log.e("RealPath", "URI: "+contentUri.toString());
try {
String[] proj = { MediaStore.Images.Media.DATA };
CursorLoader loader = new CursorLoader(getApplicationContext(),
contentUri, proj, null, null, null);
Cursor cursor = loader.loadInBackground();
int column_index = cursor
.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
return cursor.getString(column_index);
} catch (Exception e) {
Log.e("RealPath", e.toString());
e.printStackTrace();
}
return "";
}

来自 realpath catch block 的 StackTrace

   08-06 15:33:23.520: W/System.err(22083): java.lang.NullPointerException
08-06 15:33:23.536: W/System.err(22083): at android.content.ContentResolver.acquireUnstableProvider(ContentResolver.java:1097)
08-06 15:33:23.544: W/System.err(22083): at android.content.ContentResolver.query(ContentResolver.java:357)
08-06 15:33:23.544: W/System.err(22083): at android.content.ContentResolver.query(ContentResolver.java:316)
08-06 15:33:23.544: W/System.err(22083): at android.support.v4.content.CursorLoader.loadInBackground(CursorLoader.java:49)
08-06 15:33:23.544: W/System.err(22083): at ua.mirkvartir.android.frontend.AddFillActivityApp.getRealPathFromURI(AddFillActivityApp.java:842)
08-06 15:33:23.544: W/System.err(22083): at ua.mirkvartir.android.frontend.AddFillActivityApp.onActivityResult(AddFillActivityApp.java:733)
08-06 15:33:23.544: W/System.err(22083): at android.app.Activity.dispatchActivityResult(Activity.java:5436)
08-06 15:33:23.544: W/System.err(22083): at android.app.ActivityThread.deliverResults(ActivityThread.java:3188)
08-06 15:33:23.544: W/System.err(22083): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2592)
08-06 15:33:23.544: W/System.err(22083): at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2633)
08-06 15:33:23.544: W/System.err(22083): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2100)
08-06 15:33:23.544: W/System.err(22083): at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3563)
08-06 15:33:23.544: W/System.err(22083): at android.app.ActivityThread.access$700(ActivityThread.java:135)
08-06 15:33:23.544: W/System.err(22083): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1207)
08-06 15:33:23.544: W/System.err(22083): at android.os.Handler.dispatchMessage(Handler.java:99)
08-06 15:33:23.552: W/System.err(22083): at android.os.Looper.loop(Looper.java:137)
08-06 15:33:23.552: W/System.err(22083): at android.app.ActivityThread.main(ActivityThread.java:4849)
08-06 15:33:23.552: W/System.err(22083): at java.lang.reflect.Method.invokeNative(Native Method)
08-06 15:33:23.552: W/System.err(22083): at java.lang.reflect.Method.invoke(Method.java:511)
08-06 15:33:23.552: W/System.err(22083): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795)
08-06 15:33:23.559: W/System.err(22083): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:562)
08-06 15:33:23.559: W/System.err(22083): at dalvik.system.NativeStart.main(Native Method)

编辑 我在另外 5 部手机上进行了测试,一切正常。只有 LG 手机会导致问题。编辑: 我尝试使用游标加载程序而不是托管查询。同样的问题

最佳答案

如果您想知道为什么它在某些设备上没有任何问题,而在某些设备上没有问题:

正如您可能看到的那样 - 相机应用不是同一个应用。事实上,每个相机应用程序都是完全不同的,即使是那些与您的股票一起提供的应用程序。

这和你的问题有什么关系? - 没有人阻止对 MediaStore.ACTION_IMAGE_CAPTURE 使用react的应用程序完全忽略 MediaStore.EXTRA_OUTPUT Intent 额外。

您的代码假定用户选择的应用程序(或安装的默认相机应用程序)将确保将捕获的图像存储在指定的路径中。不幸的是,我从经验中知道这并不总是正确的。

悲伤但真实。如果您认为您的用户会使用此类相机应用程序或特定设备(如 LG 系列默认相机应用程序),则不能指望 MediaStore.EXTRA_OUTPUT

在这种情况下,也许您可​​以通过@Arun C Thomas 建议的方法获取图像,但令我难过的是 - 如果相机应用程序未将数据本身存储在结果。

这就是为什么您必须修改 null,或执行一些“try/catch”以防止您的应用在这种情况下崩溃...

关于android - java.lang.RuntimeException : Unable to resume activity on Lg series 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18015368/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com