Android 7.0机型崩溃处理

1,FragmentStatePagerAdapter的使用出现的崩溃

java.lang.IllegalStateException: FragmentManager is already executing transactions

at android.support.v4.app.w.b(Unknown Source)

at android.support.v4.app.l.d(Unknown Source)

at android.support.v4.app.z.finishUpdate(Unknown Source)

at android.support.v4.view.ViewPager.populate(Unknown Source)

at android.support.v4.view.ViewPager.populate(Unknown Source)

at android.support.v4.view.ViewPager.onMeasure(Unknown Source)

at android.view.View.measure(View.java:19756)

at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:715)

at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:461)

at android.view.View.measure(View.java:19756)

at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6124)

at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)

at android.support.v7.widget.ContentFrameLayout.onMeasure(Unknown Source)

at android.view.View.measure(View.java:19756)

at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6124)

at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1464)

at android.widget.LinearLayout.measureVertical(LinearLayout.java:758)

at android.widget.LinearLayout.onMeasure(LinearLayout.java:640)

at android.view.View.measure(View.java:19756)

at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6124)

at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)

at android.view.View.measure(View.java:19756)

at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6124)

at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1464)

at android.widget.LinearLayout.measureVertical(LinearLayout.java:758)

at android.widget.LinearLayout.onMeasure(LinearLayout.java:640)

at android.view.View.measure(View.java:19756)

at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6124)

at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)

at com.android.internal.policy.DecorView.onMeasure(DecorView.java:687)

at android.view.View.measure(View.java:19756)

at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2283)

at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1370)

at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1619)

at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1258)

at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6348)

at android.view.Choreographer$CallbackRecord.run(Choreographer.java:871)

at android.view.Choreographer.doCallbacks(Choreographer.java:683)

at android.view.Choreographer.doFrame(Choreographer.java:619)

at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:857)

at android.os.Handler.handleCallback(Handler.java:751)

at android.os.Handler.dispatchMessage(Handler.java:95)

at android.os.Looper.loop(Looper.java:154)

at android.app.ActivityThread.main(ActivityThread.java:6123)

at java.lang.reflect.Method.invoke(Native Method)

at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)

at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:757)

这个问题只在7.0的机型上出现,经过测试发现是在viewpager+fragment中,当viewpager中的数据需要add时,add后调用notifyDataSetChanged时发生崩溃。

解决方案:

@Override

public intgetItemPosition(Object object) {

returnPOSITION_NONE;

}


2,文件读写时的错误,根据file获取uri的值

android.os.FileUriExposedException: file:///storage/emulated/10/Mideo/Cache/IMG_20170308_222251783.jpg exposed beyond app through ClipData.Item.getUri()

at android.os.StrictMode.onFileUriExposed(StrictMode.java:1813)

at android.net.Uri.checkFileUriExposed(Uri.java:2360)

at android.content.ClipData.prepareToLeaveProcess(ClipData.java:832)

at android.content.Intent.prepareToLeaveProcess(Intent.java:8957)

at android.content.Intent.prepareToLeaveProcess(Intent.java:8942)

at android.app.Instrumentation.execStartActivity(Instrumentation.java:1583)

at android.app.Activity.startActivityForResult(Activity.java:4228)

参考链接:http://blog.csdn.net/yy1300326388/article/details/52787853

你可能感兴趣的:(Android 7.0机型崩溃处理)