Android Question App still in memory?

ValDog

Active Member
Licensed User
Longtime User
Is there a way to detect, programatically, whether an app is still in memory? I find that if my app crashes it sometimes stays in memory - which complicates things when I run it again.
 

Douglas Farias

Expert
Licensed User
Longtime User
this is a bigproblem on b4a i m trying to understand this too =(
if i use firsttime to run layouts i cant close the current activity with activity.finish
and if i need reopen the closed activity i have layout not initializated

if i dont use firsttime the layout stay on the activity i can use activity.finish too
but when i open this 2 x have memory error *-*
 
Upvote 0

NJDude

Expert
Licensed User
Longtime User
this is a bigproblem on b4a i m trying to understand this too =(
That has nothing to do with B4A, that's how Android works.

if i use firsttime to run layouts i cant close the current activity with activity.finish
and if i need reopen the closed activity i have layout not initializated
You are doing it wrong, you should NOT load layouts in FirstTime, that only triggers when the app runs for the VERY FIRST TIME.
 
Upvote 0

Douglas Farias

Expert
Licensed User
Longtime User
You are doing it wrong, you should NOT load layouts in FirstTime, that only triggers when the app runs for the VERY FIRST TIME.
if i dont use i cant load my activity again because go load my layout again and again and this give me memory error *-*
 
Upvote 0

Douglas Farias

Expert
Licensed User
Longtime User
You are doing it wrong, you should NOT load layouts in FirstTime, that only triggers when the app runs for the VERY FIRST TIME.

1 exemple

make a main activity
make a login activity
make a register activity
and make a principal activity

OK TOTAL 4 LAYOUTS

now you open the app(main), click at register and open register activity.
ok later your register done go to principal and close the current activity (register).

now you is on the principal activity and you want make a logoff and register another account.

you close the principal activity and open register again. = Memory error because you is loading layout again
if you use first time here you have layout not initializated if you dont use have memory error o_O
 
Last edited:
Upvote 0

thedesolatesoul

Expert
Licensed User
Longtime User
Is there a way to detect, programatically, whether an app is still in memory? I find that if my app crashes it sometimes stays in memory - which complicates things when I run it again.
Does your app crash or does your activity crash?
 
Upvote 0

thedesolatesoul

Expert
Licensed User
Longtime User
if i dont use i cant load my activity again because go load my layout again and again and this give me memory error *-*
Always load layout in activity_create (not first time, not resume)
If the activity is loaded again, activity_Create will not run if it is already in memory. If it is not in memory it will run, but then the memory is empty anyway.
 
Upvote 0

Douglas Farias

Expert
Licensed User
Longtime User
Upvote 0
Top