How to close an external application from my application

2

I will simplify the question:

I want to launch an external application at a time that I developed.

Intent launchIntent = getPackageManager().getLaunchIntentForPackage("com.mariana");

startActivity(launchIntent);

and with this code I open the application.

My question is how I now close that application that is external to the one I am developing

    
asked by Mariana 26.12.2017 в 19:08
source

1 answer

2

One option is to implement code in the application so that upon receiving a value in the bundle, determine to close the application.

For example

     Intent intent = new Intent(MainActivity.this, MainOtraApp.class);
     intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
     intent.putExtra("cerrar_app", true);
     startActivity(intent);

when receiving the value in the bundle that determines to close the application

if (getIntent().getBooleanExtra("cerrar_app", false)) {
            finish(); //Cierra Activity.
 }
    
answered by 26.12.2017 / 19:13
source