Reputation: 1365
Is it possible to start service without starting application? I need to refresh data of my application at-least hourly, how can I do it if user no in my application?
Upvotes: 1
Views: 9253
Reputation: 1662
you can start your service on boot. You need the following in your AndroidManifest.xml file:
In your <manifest> element:
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
In your <application> element (be sure to use a fully-qualified [or relative] class name for your BroadcastReceiver):
In MyBroadcastReceiver.java:
package com.example;
public class MyBroadcastreceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Intent startServiceIntent = new Intent(context, MyService.class);
context.startService(startServiceIntent);
}
}
Upvotes: 8
Reputation: 25793
Yes it is possible.
You can read about different methods of doing so here.
Upvotes: 1