Question

I have a few specific Questions.

I´m developing a touristic app. It works great, but after a long time launching new activities it crashes. I used the debug and i realized it uses a lot of memory, it is like the activities don´t closes altought I call.

@Override
public void onBackPressed() {
    super.onBackPressed();
    this.finish();
}

after removing some static variables and using in every new activity this flag

Intent.FLAG_ACTIVITY_CLEAR_TOP 

memory space is relieved. App performance looks good, altought it uses a lot of images and listviews because i used Holders

However, in the main activity i placed the same onBackPressed code, but after pressing it the app is not closed, the memory usage is decreased but i have my doubts

Here is my Questions

  1. Is the app really closing?

  2. It still there because is a recent app?

  3. The memory usage decreasing means that the activity FLAG_ACTIVITY_CLEAR_TOP and onBackPressed() is Working?

  4. Is this the right way to manage the activities to finish() ?

Was it helpful?

Solution

  • http://developer.android.com/training/articles/memory.html Check this out it may help you with the memory issue.
  • Secondly, if your app makes use of internet connection, do check out your code for checking the internet connection to be present or not.
  • Thirdly, it seems that you have written all the code in the onCreate() method, hence the app is taking a long time. Make use of AsyncTask.
  • Fourthly, whenever you call finish() method, the app closes. So it is the right way.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top