views:

140

answers:

2

How can I make my application to get started while my phone boots up itself.

+3  A: 

You need to use a BroadcastReceiver with android.intent.action.BOOT_COMPLETED intent.

Add following to your manifest file:

<receiver android:name="MyApp_Receiver">
    <intent-filter>
        <action android:name="android.intent.action.BOOT_COMPLETED" />
        <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>
</receiver>

MyApp_Receiver class implementing BoradcastReciever. Implement the onReceive() method and start your favorite activity from your app.

public void onReceive(Context context, Intent intent) {
    // make sure you receive "BOOT_COMPLETED"
    if ((intent.getAction() != null) && (intent.getAction().equals("android.intent.action.BOOT_COMPLETED")))
    {
        // Start the service or activity 
    }
}
Ankit Jain
Thanks a lot Guys, your input will surely find me the solution that i am trying for...Thanks a lot...
Nandagopal T
Then mark the answer as accepted..
droidgren
A: 

i have tried applying some logic with the help of your code but got run time error,so can you please provide complete source code with an example..

thanks in advance

manjunath