1、获取当前Activity,然后显示调用 finish方法
Activity pActivity = getLocalActivityManager().getCurrentActivity(); pActivity.finish();
2、向子Activity 发送广播,让其接受到广播后,自己调用finish方法。
sendBroadcast(new Intent(ACTION_INTENT_KILLSELF_MSG)); private BroadcastReceiver mReceiveBroadcast = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (action.equals(ACTION_INTENT_KILLSELF_MSG)) { finish(); } } };
getLocalActivityManager().destroyActivity("***Activity", true);结果【看调试信息:子Activity的onDestroy方法没有调用】
final ActivityManager am = (ActivityManager) getSystemService(Service.ACTIVITY_SERVICE); Log.d("FinishApplication :", getPackageName()); am.killBackgroundProcesses(getPackageName());