I am try to deal with Android memory. The problem is I want to completely free all memory and start a new activity. I found some useful answer:
Clear the entire history stack and start a new activity on Android
After that, I try to make two examples:
The first example:
Intent intent = new Intent(MainActivity.this, Main2Activity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(intent);
I am switching between two activities A and B by using the above code. Here is the picture of memory consumption:
The second example:
In MainActivity:
Intent intent = new Intent(MainActivity.this, Main2Activity.class);
startActivity(intent);
In Main2Activity:
onBackPressed();
I am also switching between two activities. The memory consumption of this example:
It looks like that Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK is not the prefect way to completely release the memory.
I am really need to know that is there anyway to release all memory like in the second example?
Thank you in advance!