0

i created an android application with no activity. I want to start a service using a system intent like BOOT_COMPLETED. I use the following receiver:

<receiver android:name=".autostart" >
        <intent-filter>
            <action android:name="android.intent.action.ACTION_POWER_CONNECTED" />
            <action android:name="android.intent.action.ACTION_POWER_DISCONNECTED" />
            <action android:name="android.intent.action.BOOT_COMPLETED" />
            <action android:name="android.intent.action.SCREEN_ON" />

        </intent-filter>

I got the problem, that the intent is not received when power is connected/disconnect or boot completed. Is an Application with no Activity even in stopped mode after install? How can I start the service? UI is not possible because the application has no activity...

J0e3gan
  • 8,740
  • 10
  • 53
  • 80

2 Answers2

0

Is an Application with no Activity even in stopped mode after install?

Yes.

UI is not possible because the applicatio has no activity...

Then add one. You need one anyway, to present your license agreement, your online help, your configuration for this background processing, and so forth. And, since your app will not run until the user launches this activity, you need to for that reason as well.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
0

Every Android application needs to be launched at least once after installation and only then it will receive any intents from system. This means an application without any gui will not work in your case.

Many applications include only "about" activity, which is a common way to deal with that.

Please see:

http://commonsware.com/blog/2011/07/13/boot-completed-regression-confirmed.html http://developer.android.com/about/versions/android-3.1.html#launchcontrols

wfranczyk
  • 420
  • 3
  • 12