question: public static void restartApp ( Activity activity ) { SharedPreferences preferences = PreferenceManager . getDefaultSharedPreferences ( activity ) ; SharedPreferences . Editor editor = preferences . edit ( ) ; if ( ! preferences . getBoolean ( RESTART_IN_PROGRESS_KEY , false ) ) { CommonActivityUtils . displayToast ( activity . getApplicationContext ( ) , "Restart the application (low memory)" ) ; Log . e ( LOG_TAG , "Kill the application" ) ; editor . putBoolean ( RESTART_IN_PROGRESS_KEY , true ) ; editor . commit ( ) ; PendingIntent mPendingIntent = PendingIntent . getActivity ( activity , 314159 , new Intent ( activity , LoginActivity . class ) , PendingIntent . FLAG_CANCEL_CURRENT ) ; AlarmManager mgr = ( AlarmManager ) activity . getSystemService ( Context . ALARM_SERVICE ) ; mgr . set ( AlarmManager . RTC , System . currentTimeMillis ( ) + 50 , mPendingIntent ) ; System . exit ( 0 ) ; } else { Log . e ( LOG_TAG , "The application is restarting, please wait !!" ) ; activity . finish ( ) ; } }
target:  Restart the application after 100ms