0

I have a Main Activity in my app for Navigation Drawer. A Fragment starts from this activity has a listview which contains some data. Further clicking on that lisview Items take me to another activity which contains a clickable link, clicking on this link takes me to the browser. This flow is working very well on devices that have RAM greater than 1GB, but it crashes the app after the back button is pressed in Devices that have RAM equal or Less than 1GB. The thing which make me wonder is, ON BACK PRESS IT GIVES ME THE MAIN ACTIVITY CONTEXT NULL on that devices. Can somebody tell me what is the issue that I am having. I have tried many code variations and following the exact life cycle for Activities and Fragments that developers site suggests.

Abid Khan
  • 2,451
  • 4
  • 22
  • 45

1 Answers1

1

For devices with less RAM, Android kills your application to save memory when your application goes to background. Hence try to save the application instance using savedInstanceState and

@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onRestoreInstanceState(savedInstanceState);
}

to restore your previous state.