Running my application in the background when I start device power in android

Possible duplicates:
how to create an application to run in android? How to autostart Android app?

Hi,

I try in one of my applications, when I am going to start, I mean the power on my groid-groid g1, my application will start automatically, but I can’t understand how can I do this, please help ..... .

+5
source share
1 answer

, , . . -, "Boot completed". AndroidManifest.xml :

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

:

<receiver android:name=".MyBroadcastReceiver">
    <intent-filter>
         <action android:name="android.intent.action.BOOT_COMPLETED" />
    </intent-filter>
</receiver>

, . MyBroadcastReceiver.java :

package com.mypackage.myapp;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

public class MyBroadcastReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context aContext, Intent aIntent) {

        // This is where you start your service
        aContext.startService(new Intent(aContext, MyService.class));
    }
}
+8

All Articles