Android start application on boot

In this Android tip, I am going to show you how to start your application automatically when Android system completely booted. To achieve this goal, you need to register a broadcast receiver for the android.intent.action.BOOT_COMPLETED system event in the AndroidManifest.xml file. It requires the android.permission.RECEIVE_BOOT_COMPLETED permission. The android.intent.action.BOOT_COMPLETED system event is fired once the Android system has completed the boot process. You should note that the application has to be started at least one time before the application is able to receive the android.intent.action.BOOT_COMPLETED system event.

<?xml version="1.0" encoding="utf-8"?>

<manifest xmlns:android=""
   android:versionName="1.0" >
     android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
     android:theme="@style/AppTheme" >
        android:label="@string/app_name" >
           <action android:name="android.intent.action.MAIN" />
           <category android:name="android.intent.category.LAUNCHER" />
     <receiver android:name="MyReceiver" >
           <action android:name="android.intent.action.BOOT_COMPLETED" />


Then create a class called MyReceiver. The MyReceiver class extends the BroadcastReceiver class. You need to override onReceive() method to start an Activity when the event that the broadcast receiver was registered happens. To start the Activity, you need to provide the current context, and the Activity to be started when you construct the Intent object.

package com.example.androidexample;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
public class MyReceiver extends BroadcastReceiver{
public void onReceive(Context context, Intent intent) {
Intent starter_intent = new Intent(context, MainActivity.class);


Posted by: Dara | post date: 09-24-2014 | Subject: Android Apps Development

write programming tip

This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages:
C, C++, C#, Java, VB.NET, Python, VBA,PHP & Mysql, SQL, JSP, ASP.NET,HTML, CSS, JQuery, JavaScript and other applications such as MS Excel, MS Access, and MS Word. However, we don't guarantee all things of the web are accurate. If you find any error, please report it then we will take actions to correct it as soon as possible.