androidandroid-activityandroid-serviceandroid-lifecycleandroid-context

How to Start android service without activity


I created an application that contain a Service that start from button click of Activity.

But I want to create a new application that doing the same as the last one - but don't have any GUI interface => that mean without any Activity.

I want to make the application to start on device boot and never stop (until the device is shutdown) .

How to do it ? Is there any way ?


Solution

  • How to do it ?

    By using Context.startService() or Context.bindService() methods.

    where Context might be Activity, Application, argument of the onReceive() method of BroadcastReceiver etc.