My app crashes and gives me the following trace:
05-08 08:49:15.228: E/AndroidRuntime(1022): FATAL EXCEPTION: main
05-08 08:49:15.228: E/AndroidRuntime(1022): java.lang.IllegalStateException: Activity has been destroyed
05-08 08:49:15.228: E/AndroidRuntime(1022): at android.support.v4.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:1365)
05-08 08:49:15.228: E/AndroidRuntime(1022): at android.support.v4.app.BackStackRecord.commitInternal(BackStackRecord.java:595)
05-08 08:49:15.228: E/AndroidRuntime(1022): at android.support.v4.app.BackStackRecord.commitAllowingStateLoss(BackStackRecord.java:578)
05-08 08:49:15.228: E/AndroidRuntime(1022): at android.support.v4.app.FragmentStatePagerAdapter.finishUpdate(FragmentStatePagerAdapter.java:161)
05-08 08:49:15.228: E/AndroidRuntime(1022): at com.automation.standards.VerticalViewPager.populate(VerticalViewPager.java:965)
05-08 08:49:15.228: E/AndroidRuntime(1022): at com.automation.standards.VerticalViewPager.populate(VerticalViewPager.java:811)
05-08 08:49:15.228: E/AndroidRuntime(1022): at com.automation.standards.VerticalViewPager.setAdapter(VerticalViewPager.java:334)
05-08 08:49:15.228: E/AndroidRuntime(1022): at com.automation.isolace.Lighting.assign_vertical_gangs_swipping(Lighting.java:505)
05-08 08:49:15.228: E/AndroidRuntime(1022): at com.automation.isolace.Lighting.select_room(Lighting.java:403)
05-08 08:49:15.228: E/AndroidRuntime(1022): at com.automation.isolace.Lighting$11.onClick(Lighting.java:351)
05-08 08:49:15.228: E/AndroidRuntime(1022): at android.view.View.performClick(View.java:4084)
05-08 08:49:15.228: E/AndroidRuntime(1022): at android.view.View$PerformClick.run(View.java:16966)
05-08 08:49:15.228: E/AndroidRuntime(1022): at android.os.Handler.handleCallback(Handler.java:615)
05-08 08:49:15.228: E/AndroidRuntime(1022): at android.os.Handler.dispatchMessage(Handler.java:92)
05-08 08:49:15.228: E/AndroidRuntime(1022): at android.os.Looper.loop(Looper.java:137)
05-08 08:49:15.228: E/AndroidRuntime(1022): at android.app.ActivityThread.main(ActivityThread.java:4745)
05-08 08:49:15.228: E/AndroidRuntime(1022): at java.lang.reflect.Method.invokeNative(Native Method)
05-08 08:49:15.228: E/AndroidRuntime(1022): at java.lang.reflect.Method.invoke(Method.java:511)
05-08 08:49:15.228: E/AndroidRuntime(1022): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
05-08 08:49:15.228: E/AndroidRuntime(1022): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
05-08 08:49:15.228: E/AndroidRuntime(1022): at dalvik.system.NativeStart.main(Native Method)
The point is I can't deal with that Activity Destroy thing as the Activity is Destroyed without calling onDestroy()
method and I figured that because I override the onDestroy method but it didn't go through it, also I checked the isDestroyed()
output but the strange thing it even not giving me true
despite I put the Line that makes the Activity crashes in a try-ctach
block, and prints isDestroyed
in the catch block (which can mean that that line itself is the one which makes the Activity crashes) and here's the code area that the app crashes in:
List<Fragment> temp_fragments = fragments; // list of fragments to add to a VerticalViewPager and return it through pageAdapter
TabAdapter2 = new LightVerticalPageAdapter(super.getSupportFragmentManager(), temp_fragments);
Tab2 = (VerticalViewPager) SomeFragment.views.findViewById(R.id.vertical_pager);// "SomeFragment" is the fragment that contains the VerticalPager and the "views" var is the var that stores Fragmrnt view when hitting fragment onViewCreated at the first time
Tab2.setAdapter(TabAdapter2); // HERE IS WHERE THE APP CRASHES AND NOT CALLS ACTIVITY onDestroy()