Closing a process when Process ID & Process Name is known


Last Updated:

  1. jhoondlani

    jhoondlani New Member This Topic's Starter

    Joined:
    Mar 12, 2010
    Messages:
    1
    Likes Received:
    0
    Hi All,
    I am having a requirement that i want to close a process that is running from my application.
    For Example :
    If a pdf file is opened in the device, i want that if my application is launched it should close.
    I am able to get the process id i.e 620 & process name : "com.htc.pdfreader"
    by using
    for (int i=0;i<appList.size();i++)
    {
    RunningAppProcessInfo rti = (RunningAppProcessInfo)appList.get(i);
    Log.v( "", "PID"+rti.pid+"Process Name"+rti.processName );
    }
    Now, for closing this i have tried
    android.os.Process.killProcess(Process ID);
    But no success.
    then i tried :
    process = Runtime.getRuntime().exec(rti.processName);
    process.destroy();
    again it was not successful.
    Can you please let me know how this can be achieved.
    Thanks
    Jaya
     

    Advertisement

Share This Page

Loading...