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
peter_strange
Posts: 19,610
Registered: ‎07-14-2008
My Device: Not Specified

Re: Programmatically rebooting the device

I would mark it as auto-start.  You need to do something that tells the Blackberry that it does need to restart.  If you mark something as auto-start, then the BlackBerry will think that it has to restart to remove whatever that module does when auto-started. 

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

Re: Programmatically rebooting the device

Attached is a zip archive containing two JDE projects that show how to do this.  One project just creates a cod file called com_samples_Restart.  This should be placed in the directory for use by the RestartTest application.

 

The RestartTest Application installs the 'restart' cod, then removes it.  Since com_sample_Restart is marked as auto-start, this will force a restart of the device.

 

You can test this on the Simulator.  You should sign the sample_Restart cod, copy the signed one into the the directory for RestartTest, then compile and sign that before testing on a device.  You only need RestartTest on the device.

 

It is not all sunshine.  Because you are actually running com_sample_Restart it may ask if it can be trusted.  In addition, the message that the user sees is not a nice 'do you want to restart' message.  I hope someone can take this and make it a more useful implementation.  But I guess it is better than nothing.

 

Thanks to osm for the providing the restart code!

osm
Contributor
osm
Posts: 13
Registered: ‎08-16-2010
My Device: Not Specified

Re: Programmatically rebooting the device

Thanks, Peter !

I have run it on simulator and it works fine. Then i sign 'restart.cod' (marked as auto-run on startup), copied this cod to RestartTest directory, and then rebuilt and sign RestartTest.

I have grant all permissions for RestartTest (options->applications), and have mark 'restart.cod' as trusted application when it asked, but RestartTest does not work on device (curve 8900), after clicking 'Restart' menu it does nothing.

I think, may it depends from OS version of BlacBerry?

Simulator's OS version is 4.7.1.40

Device - 5.0.0.411

osm
Contributor
osm
Posts: 13
Registered: ‎08-16-2010
My Device: Not Specified

Re: Programmatically rebooting the device

weird, but it works fine on device if i attach debugger and debug application on device...

Developer
QuiteSimple
Posts: 1,452
Registered: ‎11-06-2009
My Device: Torch 9810

Re: Programmatically rebooting the device

Device restarting apps are as old as the BlackBerry OS is :smileyhappy: For OS 4.6 and below there was a simple hack (just a line of code), that restarts the device for sure. This was fixed in OS 4.7, so restart apps have to use the trick with dynamic install and delete of internal app, so the device is forced to show "Reboot Now/Reboot Later". So far so good.

 

However here comes OS 5.0 ... and the things are different again. There is something new  - TrustedAppManager or something like this, which disables the trick, that worked so well in OS 4.7. Workarounds are different with different success (like sleeping for a while, install/reinstall of internal app, changing app permissions etc.) but none of them works at 100%. Afaik none of the restart solutions works on Bold 9700, no idea why, probably some tweak in the OS version.

 

No idea how the restart is working in OS 6.0 yet.

 

Well, to summarize - to find a restart solution, that works always, is a hard thing. :smileyhappy:



"When you become a level 3 developer, you learn to communicate over the ether. I'm told that level 5 developers are ascend into a higher level of existence beyond the physical realm." gord888 @ crackberry
Developer
peter_strange
Posts: 19,610
Registered: ‎07-14-2008
My Device: Not Specified

Re: Programmatically rebooting the device

QuiteSimple - thanks for the info. 

 

To OP, the problem is possibly that you are compiling in 4.7 and running in 4.6.1, since 4.6.1 was the original OS for the 8900.  If you have upgraded to OS 5.0, then the problems highlighted by QuiteSimple will most certainly be the problem. 

osm
Contributor
osm
Posts: 13
Registered: ‎08-16-2010
My Device: Not Specified

Re: Programmatically rebooting the device

Thanks to all,

Now I have to find another solution to my problem. Without restarting the device. :smileyhappy:

osm
Contributor
osm
Posts: 13
Registered: ‎08-16-2010
My Device: Not Specified

Re: Programmatically rebooting the device

Hi all,

I found that if delete the used library, then will showing restart dialog.
In my project i have the library which calling when my app run. And i just reinstall this library to rebooting device.
Works on OS 5.0.0.411.

New Developer
JGao12345678
Posts: 46
Registered: ‎07-05-2010
My Device: 9630

Re: Programmatically rebooting the device

Could you share your code in here?

Contributor
desgraci
Posts: 18
Registered: ‎11-22-2010
My Device: Not Specified

Re: Programmatically rebooting the device

So... how do you do that? Can you explain step by step, i have it working in other devices, but i share the same problem with the 8900.