Thanks! I've done it with a reciver attending ACTION_SHUTDOWN signal,
and using shared preferences to save the state.

Sorry, i'm newbie and I'm learning...

On May 4, 11:47 pm, Justin Anderson <[email protected]> wrote:
> *> Hi! I want to know if there are any method to know if is the first
> exuction of an app after reboot, or the app is alredy executed by the user
> (the app have one activity and to recivers).*
> *
> *
> Is this for an application you developed or any arbitrary app?  And, WHY?
>
> *> I'm thinking in methods like write and rewrite a token file every minute,
> and each time the app starts, check the lastmodified property to know the
> state, but i think that must be smart ways to do it.*
>
> Please tell me you're not serious... You're joking right?  Writing a file
> every minute in the background would surely drain the battery like crazy.
>
> A better solution, if you really want to know the first time your app is
> launched after a reboot is to listen for the Boot Completed broadcast
> message:http://developer.android.com/reference/android/content/Intent.html#AC...
>
> Have your receiver write out a value to SharedPreferences... something like
> a boolean key/value pair with a key of "LaunchedSinceBoot" and a value of
> "false"
>
> Then when you launch your main app read that value and act accordingly.
>  Then set the value to true so the next time you launch you skip the
> first-launch-since-boot steps...
>
> Thanks,
> Justin Anderson
> MagouyaWare Developerhttp://sites.google.com/site/magouyaware
>
>
>
>
>
>
>
> On Wed, May 4, 2011 at 5:34 AM, ferran fabregas <[email protected]> wrote:
> > Hi! I want to know if there are any method to know if is the first exuction
> > of an app after reboot, or the app is alredy executed by the user (the app
> > have one activity and to recivers).
>
> > I'm thinking in methods like write and rewrite a token file every minute,
> > and each time the app starts, check the lastmodified property to know the
> > state, but i think that must be smart ways to do it.
>
> > Any idea?
>
> > Thanks in advance,
>
> > *Ferran*
>
> >  --
> > You received this message because you are subscribed to the Google
> > Groups "Android Developers" group.
> > To post to this group, send email to [email protected]
> > To unsubscribe from this group, send email to
> > [email protected]
> > For more options, visit this group at
> >http://groups.google.com/group/android-developers?hl=en

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

Reply via email to