0

I want to start another application from my application with the help of an implicit intent and want the second activity to get stoped after a perticular interval of time.

For eg: To open chrome i could do it like

 String url = "http://www.example.com";
    Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
    i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    i.setPackage("com.android.chrome");
    try {
        startActivity(i);
    } catch (ActivityNotFoundException e) {
        // Chrome is probably not installed
        // Try with the default browser
        i.setPackage(null);
        startActivity(i);
    }

But i want chrome to automatically get closed after 1 minute. Is there any way to do this?

Hari Krishnan
  • 5,402
  • 9
  • 33
  • 49

1 Answers1

0

Yes you can kill an application; First you have to find running application via ActivityManager like this answer:

How to find the currently running applications programatically in android?

Then you can kill it like implied here:

How to kill all running applications in android?

Though me and Google don't really recommend this ><

Community
  • 1
  • 1
Keivan Esbati
  • 3,113
  • 1
  • 20
  • 36