Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to restart an application completely?

I have an application which starts a Remote Service in its first launched activity. Then, in another activity, the user can set the configuration of the application. Please note that this second activity isn't bound to the Service and I don't wish to bind it.

Now my question is : how could I restart the whole application from the second activity, after changing the configuration settings?

For now, I am using a button which onClickListener is :

public void onClick(DialogInterface dialog, int which) {
    sauvegarde();
    Intent i = getBaseContext().getPackageManager().getLaunchIntentForPackage(getBaseContext().getPackageName());
    i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    startActivity(i);
}

The problem is : it only restarts the current activity without shutting the whole application, and therefore, without restarting the service

Any ideas?

like image 699
WhiskThimble Avatar asked Jun 25 '13 10:06

WhiskThimble


People also ask

How do you restart all apps on Windows?

Restart apps command isn't something new to Windows 10. In fact, it is available in the Settings since 2017. It can be found under Settings > Accounts > Sign-in options > Restart apps. With this option enabled, Windows 10 automatically restarts all the open apps the next time you turn on or restart your computer.

How do I manually restart a program?

Ctrl + Alt + Del.

What does it mean to reset an application?

1. Default apps. For starters, resetting will clear all the default apps. For instance, when you download a third-party gallery app, if you open a photo via file explorer, your phone will ask you to choose a default app. You'll be provided with two options – Once and Always.

What does it mean to relaunch an app?

: to launch (something) again or to be launched again relaunch a ship Instead of letting the app close, then … waiting while the app relaunches, you can tell your iPad to abort your now-unwanted Home button press.—


1 Answers

try this

   public void reload() {
     Intent intent = getIntent();
     overridePendingTransition(0, 0);
     intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
     finish();

     overridePendingTransition(0, 0);
     startActivity(intent);
    }
like image 153
Michael Shrestha Avatar answered Sep 24 '22 21:09

Michael Shrestha