SIVAKUMAR.J
SIVAKUMAR.J

Reputation: 4354

Can we start a user-defined service from the broadcast receiver?

I'm developing an application for mobiles and tablet in Android. I'm using Android 2.2

In broadcast receiver, we can put some simple process (small process/small running module code snippet). It is not suited for long running process/Long running module like gps location capturing,etc.

Can we start a service (user defined service - not a Android service) from the broadcast receiver?

Upvotes: 0

Views: 265

Answers (1)

waqaslam
waqaslam

Reputation: 68167

Yes, you can start a service from BroadcastReceiver. You actually need Context to start a Service. For example:

@Override
public void onReceive(Context context, Intent intent) {

    Intent intent = new Intent(context, YourService.class);
    context.startService(intent);
}

Upvotes: 1

Related Questions