方法 一:
退出发送广播,一个BaseActivitiy中监听广播,finish自己,其余activity基础此activity
方法二:查找进程,kill之(需root?)
private void exit()
{
String packageName = "com.huawei.softclient.mtvclient";
String processId = "";
try
{
Runtime r = Runtime.getRuntime();
Process p = r.exec("ps");
BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
String inline;
while ((inline = br.readLine()) != null)
{
if (inline.endsWith(packageName))
{
break;
}
}
br.close();
StringTokenizer processInfoTokenizer = new StringTokenizer(inline);
int count = 0;
while (processInfoTokenizer.hasMoreTokens())
{
count++;
processId = processInfoTokenizer.nextToken();
if (count == 2)
{
break;
}
}
Log.d(TAG,"processId:"+processId);
r.exec("kill -15 " + processId);
}
catch (IOException ex)
{
Log.d(TAG,
"Kill process failed",
ex);
}
}