public static void doRestart(Context c){
  try {
    if (c != null) {
      PackageManager pm=c.getPackageManager();
      if (pm != null) {
        Intent mStartActivity=pm.getLaunchIntentForPackage(c.getPackageName());
        if (mStartActivity != null) {
          mStartActivity.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
          int mPendingIntentId=223344;
          PendingIntent mPendingIntent=PendingIntent.getActivity(c,mPendingIntentId,mStartActivity,PendingIntent.FLAG_CANCEL_CURRENT);
          AlarmManager mgr=(AlarmManager)c.getSystemService(Context.ALARM_SERVICE);
          mgr.set(AlarmManager.RTC,System.currentTimeMillis() + 100,mPendingIntent);
          System.exit(0);
        }
 else {
          Log.e("AppRestarter","Was not able to restart application, mStartActivity null");
        }
      }
 else {
        Log.e("AppRestarter","Was not able to restart application, PM null");
      }
    }
 else {
      Log.e("AppRestarter","Was not able to restart application, Context null");
    }
  }
 catch (  Exception ex) {
    Log.e("AppRestarter","Was not able to restart application");
  }
}

public static void doRestart ( Context c ) { try { if ( c != null ) { PackageManager pm = c . getPackageManager ( ) ; if ( pm != null ) { Intent mStartActivity = pm . getLaunchIntentForPackage ( c . getPackageName ( ) ) ; if ( mStartActivity != null ) { mStartActivity . addFlags ( Intent . FLAG_ACTIVITY_CLEAR_TOP ) ; int mPendingIntentId = 223344 ; PendingIntent mPendingIntent = PendingIntent . getActivity ( c , mPendingIntentId , mStartActivity , PendingIntent . FLAG_CANCEL_CURRENT ) ; AlarmManager mgr = ( AlarmManager ) c . getSystemService ( Context . ALARM_SERVICE ) ; mgr . set ( AlarmManager . RTC , System . currentTimeMillis ( ) + 100 , mPendingIntent ) ; System . exit ( 0 ) ; } else { Log . e ( "AppRestarter" , "Was not able to restart application, mStartActivity null" ) ; } } else { Log . e ( "AppRestarter" , "Was not able to restart application, PM null" ) ; } } else { Log . e ( "AppRestarter" , "Was not able to restart application, Context null" ) ; } } catch ( Exception ex ) { Log . e ( "AppRestarter" , "Was not able to restart application" ) ; } }
restarts the current application
