You can use the Androids AlarmManager system as follows:
Code to restart the application in your activity:
AlarmManager mgr = (AlarmManager)getSystemService(Context.ALARM_SERVICE); mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 1000, PendingIntent.getActivity(this.getBaseContext(), 0, new Intent(getIntent()), getIntent().getFlags())); System.exit(2);
An example can be found here.
UPDATE
As @CommonsWare pointed out, this is a bad way to develop your application when you need to restart it (bad practice). If you really want to do this, you can try to set an alarm to start your application a second after you kill your own process:
AlarmManager mgr = (AlarmManager)getSystemService(Context.ALARM_SERVICE); mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 1000, PendingIntent.getActivity(this.getBaseContext(), 0, new Intent(getIntent()), getIntent().getFlags())); android.os.Process.killProcess(android.os.Process.myPid());
source share