经过多次尝试之后,终于找到了开机自动启动App的解决方法
开机后会停留在锁屏页面,且短时间内如果没有进行解锁操作,屏幕会进入休眠状态,所以启动APP时需要先唤醒屏幕和解锁屏幕
定义一个广播类BootBroadcastReceiver.java
public class BootBroadcastReceiver extends BroadcastReceiver { static final String ACTION = "android.intent.action.BOOT_COMPLETED"; @Override public void onReceive(Context context, Intent intent) { //屏幕唤醒 PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE); PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.SCREEN_DIM_WAKE_LOCK, "BootBroadcastReceiver"); wl.acquire(); //屏幕解锁 KeyguardManager km = (KeyguardManager) contex