My android app keeps crashing when I change the device font.


Last Updated: 2012-10-01 09:32:40
  1. Trollypolly

    Trollypolly New Member

    I have an android app I am working on in Eclipse. It has 1 activity with some fragments in it which works fine. But when I go into any of my fragments, which either consist of a layout statically made or dynamically made, I then hit the menu button and go to the "Display" section of my phone to change the font of my android device Ex) Normal to Large or Large to Normal. Once I do that I open my app again thinking that the text in my app should grow/shrink and still be on the same fragment like I have seen in other apps but instead it just crashes.

    I have a feeling it has to do something with the fragment or my activity's lifecycle methods but I honestly do not even know where to begin. I understand how the lifecycles flow but as for putting code into these methods to fix this issue I do not even know where to begin. The only methods so far I have used/Override with my code in it is the "onCreate()" in my Activity, onActivityCreated() in my ListFragment and "onCreateView()" in my fragments. Does anyone have a solution as to why it is doing this?

    EDIT: More information to help possibly solve this issue,


    This code snippet here is when I go from Activity (MainActivity) -> ListFragment (JungleListFragment) -> Fragment (JungleInfo)
    Code (Text):
    1.  
    2. 10-01 05:10:25.734: I/MainActivity(712): onCreate
    3. 10-01 05:10:26.564: I/MainActivity(712): onStart
    4. 10-01 05:10:26.564: I/MainActivity(712): onResume
    5. 10-01 05:10:29.304: I/JungleListFragment(712): onAttach
    6. 10-01 05:10:29.304: I/JungleListFragment(712): onCreateView
    7. 10-01 05:10:29.344: I/JungleListFragment(712): onActivityCreated
    8. 10-01 05:10:31.234: I/JungleListFragment(712): onDestroyView
    9. 10-01 05:10:31.234: I/JungleInfo(712): onAttach
    10. 10-01 05:10:31.234: I/JungleInfo(712): onCreate
    11. 10-01 05:10:31.234: I/JungleInfo(712): onCreateView
    12. 10-01 05:10:31.664: I/JungleInfo(712): onActivityCreated
    13.  
    Now I just went and changed the devices font size and then re-entered my app and this is what I get:

    Code (Text):
    1.  
    2. 10-01 05:14:06.783: I/JungleInfo(712): onPause
    3. 10-01 05:14:06.783: I/MainActivity(712): onPause
    4. 10-01 05:14:08.463: I/MainActivity(712): onStop
    5. 10-01 05:14:24.653: I/JungleInfo(712): onDestroyView
    6. 10-01 05:14:24.693: I/MainActivity(712): onDestroy
    7. 10-01 05:14:24.733: I/JungleListFragment(712): onAttach
    8. 10-01 05:14:24.733: I/JungleInfo(712): onAttach
    9. 10-01 05:14:24.733: I/JungleInfo(712): onCreate
    10. 10-01 05:14:24.733: I/MainActivity(712): onCreate
    11. 10-01 05:14:25.423: I/JungleInfo(712): onCreateView
    12. 10-01 05:14:25.563: D/AndroidRuntime(712): Shutting down VM
    13. 10-01 05:14:25.643: W/dalvikvm(712): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
    14. 10-01 05:14:25.743: E/AndroidRuntime(712): FATAL EXCEPTION: main
    15. 10-01 05:14:25.743: E/AndroidRuntime(712): java.lang.RuntimeException: Unable to start activity ComponentInfo{(*packageinfo*).MainActivity}: java.lang.NullPointerException
    16.  
    Hope this may help find a solution as to why it is doing this cause I am just completely lost.

    Advertisement
  2. Kostas G

    Kostas G Active Member

    You have a NullPointerException in your Activity. Can you post the full log and your Java code (especially the OnCreate method)?

Share This Page