Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>It's possible to register your own application service for starting automatically when the device has been booted. You need this, for example, when you want to receive push events from a http server and want to inform the user as soon a new event occurs. The user doesn't have to start the activity manually before the service get started...</p> <p>It's quite simple. First give your app the permission RECEIVE_BOOT_COMPLETED. Next you need to register a BroadcastReveiver. We call it BootCompletedIntentReceiver.</p> <p>Your Manifest.xml should now look like this:</p> <pre><code>&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.jjoe64"&gt; &lt;uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/&gt; &lt;application&gt; &lt;receiver android:name=".BootCompletedIntentReceiver"&gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.BOOT_COMPLETED" /&gt; &lt;/intent-filter&gt; &lt;/receiver&gt; &lt;service android:name=".BackgroundService"/&gt; &lt;/application&gt; &lt;/manifest&gt; </code></pre> <p>As the last step you have to implement the Receiver. This receiver just starts your background service.</p> <pre><code>package com.jjoe64; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.preference.PreferenceManager; import com.jjoe64.BackgroundService; public class BootCompletedIntentReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { if ("android.intent.action.BOOT_COMPLETED".equals(intent.getAction())) { Intent pushIntent = new Intent(context, BackgroundService.class); context.startService(pushIntent); } } } </code></pre> </blockquote> <p>From <a href="http://www.jjoe64.com/2011/06/autostart-service-on-device-boot.html">http://www.jjoe64.com/2011/06/autostart-service-on-device-boot.html</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload