|
|
|
@ -429,28 +429,35 @@ public class MainActivity extends AppCompatActivity {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(View v) {
|
|
|
|
|
restartSelfWithStartActivity();
|
|
|
|
|
// restartSelfWithAlarmManager();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void restartSelfWithStartActivity() {
|
|
|
|
|
|
|
|
|
|
Context context = MainActivity.this;
|
|
|
|
|
final Context context = getApplicationContext();
|
|
|
|
|
|
|
|
|
|
Intent intent = new Intent(context, MainActivity.class);
|
|
|
|
|
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK| Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
|
|
|
|
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
|
|
|
|
|
|
|
|
int noDelay = 1;
|
|
|
|
|
intent.putExtra("noDelay", noDelay);
|
|
|
|
|
intent.putExtra("reason", "Manual Restart From MainActivity");
|
|
|
|
|
|
|
|
|
|
// finish();
|
|
|
|
|
context.startActivity(intent);
|
|
|
|
|
|
|
|
|
|
System.exit(0);
|
|
|
|
|
final Handler handler = new Handler();
|
|
|
|
|
finish();
|
|
|
|
|
handler.postDelayed(new Runnable() {
|
|
|
|
|
@Override
|
|
|
|
|
public void run() {
|
|
|
|
|
System.exit(0);
|
|
|
|
|
}
|
|
|
|
|
}, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void restartSelfWithAlarmManager() {
|
|
|
|
|
Intent intent = new Intent(MainActivity.this, MainActivity.class);
|
|
|
|
|
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK| Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
|
|
|
|
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
|
|
|
|
|
|
|
|
int noDelay = 1;
|
|
|
|
|
intent.putExtra("noDelay", noDelay);
|
|
|
|
|