当我重新启动应用程序时,此代码一直工作到棉花糖。当屏幕打开时,此代码即使在Nougat也可以使用。只有当屏幕关闭时,这段代码才能重新启动Nougat中的应用程序
任何帮助将不胜感激:
Intent mStartActivity = new Intent(getBaseContext(), MainClass.class);
int mPendingIntentId = 123456;
PendingIntent mPendingIntent = PendingIntent.getActivity(getBaseContext(), mPendingIntentId, mStartActivity, PendingIntent.FLAG_UPDATE_CURRENT);
AlarmManager mgr = (AlarmManager)getBaseContext().getSystemService(Context.ALARM_SERVICE);
mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 1000, mPendingIntent);
finish();
System.gc();
System.exit(0);