casimir / simpleDeadlines

Simple Deadlines is a deadline manager meant to be as simple as possible to use. Less is more!
https://play.google.com/store/apps/details?id=com.casimirlab.simpleDeadlines
GNU General Public License v3.0
22 stars 6 forks source link

IllegalStateException: Fragment not attached to Activity #51

Open lingling-fan opened 7 years ago

lingling-fan commented 7 years ago

//package name: com.casimirlab.simpleDeadlines //version: 3.2.1 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.casimirlab.simpleDeadlines/com.casimirlab.simpleDeadlines.ui.MainActivity}: java.lang.IllegalStateException: Fragment DeadlineListFragment{ad2ef970} not attached to Activity at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261) at android.app.ActivityThread.access$600(ActivityThread.java:141) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:5103) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:525) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.IllegalStateException: Fragment DeadlineListFragment{ad2ef970} not attached to Activity at android.support.v4.app.Fragment.getLoaderManager(Fragment.java:881) at com.casimirlab.simpleDeadlines.ui.DeadlineListFragment.setGroupFilter(DeadlineListFragment.java:178) at com.casimirlab.simpleDeadlines.ui.MainActivity$2.onPageSelected(MainActivity.java:85) at android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:548) at android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:514) at android.support.v4.view.ViewPager.onRestoreInstanceState(ViewPager.java:1287) at android.view.View.dispatchRestoreInstanceState(View.java:12284) at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2620) at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2626) at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2626) at android.view.View.restoreHierarchyState(View.java:12262) at com.android.internal.policy.impl.PhoneWindow.restoreHierarchyState(PhoneWindow.java:1647) at android.app.Activity.onRestoreInstanceState(Activity.java:938) at android.app.Activity.performRestoreInstanceState(Activity.java:910) at android.app.Instrumentation.callActivityOnRestoreInstanceState(Instrumentation.java:1138) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2189)

lingling-fan commented 7 years ago

package name: com.casimirlab.simpleDeadlines version: 3.2.1 Exception: java.lang.IllegalStateException: Fragment DeadlineListFragment{ad2ef970} not attached to Activity Category: Lifecycle Description: When doing time-consuming operation in background thread(e.g, AsyncTask), a new Fragment has been created in the meantime, and was detached to the Activity before the background thread finished. The code in UI thread(e.g.,onPostExecute) calls upon a detached Fragment, throwing such exception. Fix solution: 1: Cancel the background thread when pausing or stopping the Fragment 2: Use isAdded() to check whether the fragment is attached and then to getResources() from activity.

I'm looking forward to your reply.