I need to know why my app didn't run immediately after booting in android real phone? My app runs but after a few second of booting.
My Code is
public class AutoStart extends BroadcastReceiver{
@Override
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)){
Intent i = new Intent(context, MyActivity.class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
}
}
}
My activity is running, but after few Seconds of the boot completed. Is it Possible to reduce this few second?
I want to run my app immediately. I Don't want to allow user to access the phone.
This can increase you priority but still there would be some delay. Since android first load its OS and the all the other activity starts.
<receiver
android:name=".AutoStart"
android:enabled="true"
android:exported="true"
<intent-filter android:priority="1000">
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
I run through this problem too. To anyone still searching for solution:
I want to run my app immediately. I Don't want to allow user to access the phone.
Consider turning your app into home launcher. Make changes in the manifest:
Add to your activity
android:launchMode="singleTask"
Add to intent filter in activity
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.HOME" />
After that it will launch immediately with system, not showing to user anything else.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With