Skip to content Skip to sidebar Skip to footer

Super.oncreate(savedinstancestate) Crashes When Activity Resumes

My app's main activity starts fine, works fine, everything is dandy - but if you switch away to another app and the app is destroyed by the garbage collector, when you move back to

Solution 1:

E/AndroidRuntime(25512): Caused by: android.support.v4.app.Fragment$InstantiationException: Unable to instantiate fragment ambious.androidtroper.MainActivity$ArticleFragment: Ensure the following:

  • Class name exists
  • Class is public
  • Class is static
  • Empty public constructor exists

try this, making it static class:

publicstaticclassArticleFragmentextendsFragment  {
   publicArticleFragment(){
      //Empty constructor
   }
}

Solution 2:

A couple of things to check:

You should either remove the constructor on ArticleFragment, or be sure to call super() within your constructor.

Secondly, you might have to declare ArticleFragment as a static nested class within your activity. I typically write fragments as separate classes rather than as inner classes so I'm unsure of the ramifications to the android lifecycle when you declare them as you have..

Solution 3:

activity life cycle

Process is killed and your data will be clear but when you resume app then method onCreate will be call and the state previously will try to restore. However, your app cannot restore. Because everything was cleared. the classes has been unloaded out of memory when other app need more memory.

Post a Comment for "Super.oncreate(savedinstancestate) Crashes When Activity Resumes"