Skip to content Skip to sidebar Skip to footer

Automatically Run An Application On Android Phone Startup

I want to start my application when phone startup I just follow tutorial from here but it doesn't work in my device. Please see my method: public class MyStartUpReciever extends B

Solution 1:

I've done something similiar, but I was starting activity. Here is how I done it:

In Manifest:

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

In Java code:

publicclassBootUpReceiverextendsBroadcastReceiver {
    @OverridepublicvoidonReceive(Context context, Intent intent) {
        PendingIntenti= PendingIntent.getActivity(context, 0, newIntent(
                context,MainActivity.class),
                Intent.FLAG_ACTIVITY_NEW_TASK);
        AlarmManagermgr= (AlarmManager) context
                .getSystemService(Context.ALARM_SERVICE);
        mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 20000, i);
    }
}

Your code seems to be correct, but try using PendingIntent ;) Hope it helps you

Solution 2:

try like this....

@OverridepublicvoidonReceive(Context context, Intent intent) {
        // TODO Auto-generated method stubIntenti=newIntent(context, BootingActivity.class);
        i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(i);
    }

in manifest file...

<receiverandroid:name=".BroadcastReceiver"><intent-filter><actionandroid:name="android.intent.action.BOOT_COMPLETED"></action><categoryandroid:name="android.intent.category.DEFAULT"></category></intent-filter></receiver>

Solution 3:

    @Override
    publicvoidonReceive(Context context, Intent intent) {
        // TODO Auto-generated method stubif (intent.getAction().equals("android.intent.action.BOOT_COMPLETED")) {
            context.startService(new Intent(context, BootService.class));
        }
    }

and next you should implements BootService class extended Service

Post a Comment for "Automatically Run An Application On Android Phone Startup"