在Samsung Galaxy Tab 4 7.0上触发第二次(或后续)调用相机意图时应用程序崩溃

时间:2014-12-11 12:30:18

标签: java android android-studio android-camera-intent

使用Android Studio 1.0,我有一个带有listview的活动,使用适配器显示自定义布局。 ' setOnItemClickListener'调用第一次完美运行的相机意图 - ' onActivityResult'检索图像,发布图像,删除文件并回收内存(内存监视器确认GB在此处正常工作)。它第二次触发,应用程序在“startActivityForResult”之后崩溃。呼叫。

LogCat报告它无法找到与我的自定义布局相对应的资源ID#0x7f030012。令我困惑的是为什么' doCallbacks'和' onMeasure'当'startActivityForResult'方法第二次被称为。

该应用程序在Titan和三星Galaxy S3设备上运行良好,但在自定义平板电脑4.4.4 API 19(2560 x 1600)模拟器和Galaxy Tab 4 7.0设备上失败。


清单摘录:

<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

活动的setOnItemClickListener片段:

Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);
startActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE);

logcat的:

  

12-11 13:10:3​​8.539 4122-4122 / com.company.product W / ResourceType:   无法在包0中输入0x7f030012(t = 2 e = 18)(错误   -75)12-11 13:10:3​​8.539 4122-4122 / com.company.product D / AndroidRuntime:关闭VM 12-11 13:10:3​​8.539
  4122-4122 / com.company.product W / dalvikvm:threadid = 1:线程退出   未捕获的异常(组= 0x41769c08)12-11 13:10:3​​8.579
  4122-4122 / com.opsi.zeno E / AndroidRuntime:FATAL EXCEPTION:main       过程:com.opsi.zeno,PID:4122       android.content.res.Resources $ NotFoundException:资源ID#0x7f030012               在android.content.res.Resources.getValue(Resources.java:2350)               在android.content.res.Resources.loadXmlResourceParser(Resources.java:3678)               在android.content.res.Resources.getLayout(Resources.java:2166)               在android.view.LayoutInflater.inflate(LayoutInflater.java:396)               在com.company.product.adapters.WorkflowAdapter.getView(WorkflowAdapter.java:60)               在android.widget.AbsListView.obtainView(AbsListView.java:2738)               在android.widget.ListView.measureHeightOfChildren(ListView.java:1274)               在android.widget.ListView.onMeasure(ListView.java:1186)               在android.view.View.measure(View.java:17478)               在android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5363)               在android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1410)               在android.widget.LinearLayout.measureVertical(LinearLayout.java:695)               在android.widget.LinearLayout.onMeasure(LinearLayout.java:588)               在android.view.View.measure(View.java:17478)               在android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5363)               在android.widget.FrameLayout.onMeasure(FrameLayout.java:310)               在android.view.View.measure(View.java:17478)               在android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5363)               在com.android.internal.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:412)               在android.view.View.measure(View.java:17478)               在android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5363)               在android.widget.FrameLayout.onMeasure(FrameLayout.java:310)               在com.android.internal.policy.impl.PhoneWindow $ DecorView.onMeasure(PhoneWindow.java:2548)               在android.view.View.measure(View.java:17478)               在android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2285)               在android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1396)               在android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1595)               在android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1254)               在android.view.ViewRootImpl $ TraversalRunnable.run(ViewRootImpl.java:6624)               在android.view.Choreographer $ CallbackRecord.run(Choreographer.java:812)               在android.view.Choreographer.doCallbacks(Choreographer.java:612)               在android.view.Choreographer.doFrame(Choreographer.java:582)               在android.view.Choreographer $ FrameDisplayEventReceiver.run(Choreographer.java:798)               在android.os.Handler.handleCallback(Handler.java:733)               在android.os.Handler.dispatchMessage(Handler.java:95)               在android.os.Looper.loop(Looper.java:146)               在android.app.ActivityThread.main(ActivityThread.java:5602)               at java.lang.reflect.Method.invokeNative(Native Method)               在java.lang.reflect.Method.invoke(Method.java:515)               在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:1283)               在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)               在dalvik.system.NativeStart.main(本地方法)

1 个答案:

答案 0 :(得分:0)

这被证明是某种线程问题。我在'startActivityForResult()'执行代码中添加了一个延迟,它修复了问题。它更像是一个黑客而不是一个正确的解决方案,也许有人可以解决这个问题,也就是说,为什么Android会在新活动启动时触发当前活动的线程?