I read that when Android are low on memory, it will kill the activity that is on background.
When returning to application, Android will restore from the top most stack, so when the Activity called other killed Activity that has 'static', it could return null because it hasn't recovered yet.
Question is, how about static final variable ? My understanding is that since it's final, it won't be nulled by Android and keep it's value, even when Android killed the Activity holding it.
The use case is fyi :
Activity A :
private static final String EXTRA_KEY = "key"
void goToB(){
Intent intent = new Intent(this, B.class);
intent.putExtra(EXTRA_KEY,"value");
}
Activity B:
void getExtra(){
getIntent.getExtras(A.EXTRA_KEY);
}
If I'm on Activity B, put the apps on background and Android kill the activities because of memory, is it possible for A.EXTRA_KEY to be null ?
Also is this the recommended way to use EXTRA_KEY as a constant ? Thank you