Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
Posts: 152
Registered: ‎07-28-2011
My Device: Bold 9900
My Carrier: MTN
Accepted Solution

Detect a "battery pull" or phone reset

Is it possible to detect when your BlackBerry has been reset or you've removed the battery?

 

Weird question, I know but it would be awesome if it's possible.

Highlighted
Developer
Posts: 16,784
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Detect a "battery pull" or phone reset

you could use an autostart application for this, yes.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 152
Registered: ‎07-28-2011
My Device: Bold 9900
My Carrier: MTN

Re: Detect a "battery pull" or phone reset

Not exactly what I want to do. Doesn't really answer my Q either.

Developer
Posts: 16,784
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Detect a "battery pull" or phone reset

an autostart application runs after the device starts up.
if the device is not rebooted the autostart application is not run anew.

maybe you can detail your request.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 19,631
Registered: ‎07-14-2008
My Device: Not Specified

Re: Detect a "battery pull" or phone reset

Actually Simon's answer was correct if perhaps a little too brief for you.

 

Here is a little more. 

 

The usual way would be to have your application autostart.  Most people do this via an Alternate Entry.  So they have a part of their application that autostarts and sets everything up, and another part that runs when the icon is pressed.  How to do this is described here:

http://supportforums.blackberry.com/t5/Java-Development/Set-up-an-alternate-entry-point-for-an-appli...

 

Be aware that an application is also autostarted on initial install.  To detect the difference, you need to check, in your autostart application, that the device is 'inStartUp - see

ApplicationManager.inStartup().

 

Hopefully this is enough. 

Developer
Posts: 152
Registered: ‎07-28-2011
My Device: Bold 9900
My Carrier: MTN

Re: Detect a "battery pull" or phone reset

Basically, I have a persistant store for certain objects/variables that I use for "run once" case. In this case, ApplicationMenuItems, but the issue is that if you've rebooted your phone then the menu items need to be reregistered. At the point, my variable/flag is still set to show that the menu items have been registered and thus, will not register them again unless you remove and re-install the app ... o_O

Developer
Posts: 19,631
Registered: ‎07-14-2008
My Device: Not Specified

Re: Detect a "battery pull" or phone reset

Put variables that you want 'reset' in RuntimeStore - it is lost on device restart

Developer
Posts: 152
Registered: ‎07-28-2011
My Device: Bold 9900
My Carrier: MTN

Re: Detect a "battery pull" or phone reset

I thought about that but would that not remove the variable on device restart instead of "reset" it?

Developer
Posts: 19,631
Registered: ‎07-14-2008
My Device: Not Specified

Re: Detect a "battery pull" or phone reset

[ Edited ]

Yes, but I use that to mean 'reset'.  In other words, at start-up time, if the RuntimeStore object is not present, the application knows the device has been restarted or the application is freshly installed.

Contributor
Posts: 28
Registered: ‎03-15-2011
My Device: 9700
My Carrier: Vodafone

Re: Detect a "battery pull" or phone reset

Hi Dionysus,

 

yes you can detect battery pull or device restart , just make your application autostart and implement SystemListener in your application , you will get call on powerUp().