Android 异常后如何重启应用

    public static final String PKG = "com.test";
    public static final String CLS = "com.test.activity.StartActivity";

   public void restartApp() {

        Intent intent = new Intent();
        intent.setClassName(Globals.PKG, Globals.CLS);
        PendingIntent restartIntent = PendingIntent.getActivity( getApplicationContext(), 0, intent,
                Intent.FLAG_ACTIVITY_NEW_TASK);
        AlarmManager am = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
        am.set(AlarmManager.RTC, System.currentTimeMillis() + 3000, restartIntent);
        System.exit(0);        
    }

你可能感兴趣的:(Android)