Wednesday, 18 January 2012

Autostart our own application when android device bootup compeleted


Autostart  own application at bootup.

when you power on the device open our application below the codes.
through receiver we can achive this one .

Androidmenifest.xml

 <receiver android:enabled="true" android:name=".OpenOurAppReceiver"
        android:permission="android.permission.RECEIVE_BOOT_COMPLETED">

        <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
                <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
OpenOurAppReceiver.class
public class
 OpenOurAppReceiver extends BroadcastReceiver{
    @Override
    public void onReceive(Context context, Intent intent) {
          
  Intent i = new Intent(context, MainActivity.class);
            i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
               context.startActivity(i);  

    }

}