关闭应用程序,并从RAM杀死它并从、应用程序、RAM

由网友(别闹)分享简介:您好我想结束我的应用程序,还需要通过点击按钮,从RAM杀死它。我使用这种方法,但它只是最大​​限度地减少应用程序,并没有关闭完整的应用程序。该怎么办 ? 公共无效AppExit(){this.finish();意向意图=新的意图(Intent.ACTION_MAIN);intent.addCategory(Int...

您好我想结束我的应用程序,还需要通过点击按钮,从RAM杀死它。 我使用这种方法,但它只是最大​​限度地减少应用程序,并没有 关闭完整的应用程序。该怎么办 ?

 公共无效AppExit()
{

    this.finish();
    意向意图=新的意图(Intent.ACTION_MAIN);
    intent.addCategory(Intent.CATEGORY_HOME);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(意向);
    }
 

解决方案

调用:

System.exit(0) Process.killProcess(android.os.Process.myPid());

这两者都是绝对不是的好主意的!

相反,使用活动的结束(); 方法 - 让机器人处理内存管理,它是这样做的。

很好的清理!

如果您不希望您的活动,在活动堆栈显示,标志, Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP 通常会足以启动另一个活动。

或的指定的的Andr​​oidManifest.xml 在你的活动代码,机器人: noHistory =真正的

Hibernator Pro高级破解版 v2.11.3下载 zd423

hi I want to close my application and also want kill it from ram by clicking button. i am using this method, but it just minimize application and didn't close complete app. what to do ?

public void AppExit()
{

    this.finish();
    Intent intent = new Intent(Intent.ACTION_MAIN);
    intent.addCategory(Intent.CATEGORY_HOME);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(intent);
    }

解决方案

Calling:

System.exit(0); Process.killProcess(android.os.Process.myPid());

Both of which are definitely not a good idea!

Instead use the activity's finish(); method - let Android handle the cleanup of RAM management, which it is very good in doing so!

If you do not want your activity to be shown in the activity stack, the flags, Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP would usually suffice for launching another activity.

OR specify in your AndroidManifest.xml in your activity tag, android:noHistory="true".

阅读全文

相关推荐

最新文章