var Form1: TForm1; implementation uses System.DateUtils, Androidapi.JNI.GraphicsContentViewText, FMX.Platform.Android, Androidapi.Helpers, Androidapi.JNI.App ; {$R *.fmx} procedure ReStartApp(); var LPM : JPackageManager; LIntent_Start : JIntent; LPendingIntent : JPendingIntent; LMS : Int64; begin LPM := TAndroidHelper.Context.getPackageManager(); LIntent_Start := LPM.getLaunchIntentForPackage( TAndroidHelper.Context.getPackageName() ); LIntent_Start.addFlags( TJIntent.JavaClass.FLAG_ACTIVITY_CLEAR_TOP ); LPendingIntent := TJPendingIntent.JavaClass.getActivity( TAndroidHelper.Context, 223344 {RequestCode}, LIntent_Start, TJPendingIntent.JavaClass.FLAG_CANCEL_CURRENT ); // System.currentTimeMillis() is "wall clock time in UTC". // LMS := DateTimeToUnix( Now, False {InputIsUTC} ) * 1000; //slow LMS := LMS + System.DateUtils.MilliSecondOf( Now ); //Fast TAndroidHelper.AlarmManager.&set( TJAlarmManager.JavaClass.RTC, LMS + 500, LPendingIntent ); TAndroidHelper.Activity.finish(); end;
https://forums.embarcadero.com/thread.jspa?threadID=252411
进一步学习上面代码,可以参考:https://blog.csdn.net/lindroid/article/details/83621590