If I create a remote service in my app then will it accessible to other apps too. I want that it should not be accessible to other apps. But I need to create a remote service since it needs to keep running in the background.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes. That is the point behind having a remote service.
Then do not make a remote service.
A remote service will not “keep running in the background”, any more than a local service will “keep running in the background”. You cannot write a service that will “keep running in the background” very long. That is because developers have tried writing services that “keep running in the background”, causing problems for users. Users have responded with task killers, and the Android OS has responded by terminating services that run too long.
If your service is part of the foreground user experience (e.g., a music player), use
startForeground()and aNotificationto minimize the odds of your service being terminated.Otherwise, please redesign your application to not require a service that will “keep running in the background”. For example, to do some work every 15 minutes, use
AlarmManagerand anIntentService.