|
|
|
@ -1030,36 +1030,30 @@ public class MicroPhotoService extends Service {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void restartApp(Context context, String packageName) {
|
|
|
|
|
/*
|
|
|
|
|
Context context = MicroPhotoService.this.getApplicationContext();
|
|
|
|
|
Intent intent = getPackageManager().getLaunchIntentForPackage(context.getPackageName());
|
|
|
|
|
|
|
|
|
|
Intent intent = new Intent(context, MainActivity.class);
|
|
|
|
|
int noDelay = 1;
|
|
|
|
|
intent.putExtra("noDelay", noDelay);
|
|
|
|
|
PendingIntent restartIntent = PendingIntent.getActivity(context, 0, intent, 0);
|
|
|
|
|
AlarmManager mgr = (AlarmManager)getSystemService(Context.ALARM_SERVICE);
|
|
|
|
|
mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 1000, restartIntent); // 1秒钟后重启应用
|
|
|
|
|
|
|
|
|
|
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
|
|
|
|
context.startActivity(intent);
|
|
|
|
|
System.exit(0);
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
Intent intent = context.getPackageManager().getLaunchIntentForPackage(context.getPackageName());
|
|
|
|
|
int noDelay = 1;
|
|
|
|
|
intent.putExtra("noDelay", noDelay);
|
|
|
|
|
PendingIntent restartIntent = PendingIntent.getActivity(context, 0, intent, 0);
|
|
|
|
|
AlarmManager mgr = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
|
|
|
|
|
// mgr.setExactAndAllowWhileIdle(AlarmManager.RTC, System.currentTimeMillis() + 500, restartIntent);
|
|
|
|
|
|
|
|
|
|
mgr.setExactAndAllowWhileIdle(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + 500, restartIntent);
|
|
|
|
|
mgr.setExactAndAllowWhileIdle(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + 500, restartIntent);
|
|
|
|
|
|
|
|
|
|
System.exit(0);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
Intent LaunchIntent = context.getPackageManager().getLaunchIntentForPackage(packageName);
|
|
|
|
|
LaunchIntent.putExtra("noDelay", 1);
|
|
|
|
|
LaunchIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
|
|
|
|
context.startActivity(LaunchIntent);
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
}
|
|
|
|
|
public void enableGps(boolean enabled) {
|
|
|
|
|
SysApi.enableGps(getApplicationContext(), enabled);
|
|
|
|
|