Reputation: 16363
In my application, I used to start through Intent.ACTION_VIEW
external application for viewing images/videos and so on.
For security reasons I need to close started Intent from my application. How to do that?
Upvotes: 1
Views: 1889
Reputation: 33782
If you know which application you're launching use
android.os.Process.killProcess(pid);
You can get the process id from the running process using this class: RunningAppProcessInfo
You can't get that directly, because that is a violation of security:
Why don't you limit the choices given to the user by calling setPackage()
If you really want to know which application was launched, here is the code
ActivityManager am = (ActivityManager) context.
getSystemService(Activity.ACTIVITY_SERVICE);
String packageName = am.getRunningTasks(1).get(0).topActivity.getPackageName();
String className = am.getRunningTasks(1).get(0).topActivity.getClassName();
Upvotes: 2