1

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?

Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880
Stas
  • 1,355
  • 6
  • 22
  • 40
  • possible duplicate - http://stackoverflow.com/questions/2127044/how-to-start-android-service-on-installation but yeah... there's no direct way of starting the service after installation. I haven't tried the solution mentioned there either, so I can't judge. – Kevin D. Jun 08 '12 at 08:34

2 Answers2

8

you can start your service on boot. You need the following in your AndroidManifest.xml file:

  1. In your <manifest> element:

    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

  2. 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);
    }
}
Irfan Anwar
  • 1,878
  • 17
  • 30
Krishna Shrestha
  • 1,662
  • 14
  • 38
1

Yes it is possible.

You can read about different methods of doing so here.

Community
  • 1
  • 1
Benito Bertoli
  • 25,285
  • 12
  • 54
  • 61