Restart Android Service

This is the forum for miscellaneous technical/programming questions.

Moderator: 2ffat

Restart Android Service

Postby Lena » Fri Sep 01, 2017 1:59 am

I use this article for create Android Service:
How to use Android Service(TAndroidService) in C++Builder
How restart Android Service if device reboot?
Thanks.
Lena
BCBJ Master
BCBJ Master
 
Posts: 483
Joined: Sun Feb 06, 2011 1:28 pm

Re: Restart Android Service

Postby rlebeau » Fri Sep 01, 2017 6:24 pm

You need to implement a BroadcastReceiver (in Java) to handle the BOOT_COMPLETED broadcast, then it can start your service. And you need to enable the RECEIVE_BOOT_COMPLETED permission.

Auto start Delphi XE5 Android App after boot
(This is written for Delphi, but you can adapt it to C++Builder)

Also be aware that BOOT_COMPLETED is not sent to an app until the user runs the app at least once (to avoid malware running on bootup). And if the user does a Force Close on the app, it will not receive BOOT_COMPLETED anymore until the user runs the app again at least once.
Remy Lebeau (TeamB)
Lebeau Software
User avatar
rlebeau
BCBJ Author
BCBJ Author
 
Posts: 1416
Joined: Wed Jun 01, 2005 3:21 am
Location: California, USA


Return to Technical

Who is online

Users browsing this forum: Yahoo [Bot] and 6 guests