On Tuesday, April 17, 2012 11:59:42 AM UTC-4, Anatoliy Lysenko wrote:
>
> Hi, 
> In my NDK project I have two global variables, int and pointer. 
>
> When I install my app and run it for first time, all global variables 
> are empty. 
> When I exit app and start it again, in both variables stored values 
> from previous run. 
>

This is actually not strictly an NDK issue, rather then NDK is making a 
universal aspect of Android apps a bit more easy to see.

On an ordinary system, programmers think in terms of a process.  These 
exist on android too, but there is not a 1-1 correspondence with 
activities.  Even when all activities and services hosted by a process 
entirely finish, android will try to keep the process around for a faster 
restart of that app, killing it off only if the system becomes memory 
constrained.  In the ordinary case, when a user re-enters a recent 
activity, it runs in the "old" process that is still around from the last 
time.  But that is of course not always the case - sometimes the old 
process has been reaped (or it has crashed, or was never previously run) 
and a new one must be created.

The NDK is not unique in having certain things that can survive with the 
process, irrespective of the component activities or services - that can 
happen with the java code too.  However, appropriate practices for handling 
this for ndk code might indeed be better on the ndk group.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to