force close the application

前端 未结 4 880
闹比i
闹比i 2021-01-07 09:30

I am new to android and stuck up with an issue.

I want to know how to force close the application programmatically and restart it again. I am trying this because i a

4条回答
  •  爱一瞬间的悲伤
    2021-01-07 10:22

    To force closing application just call:

    android.os.Process.killProcess(android.os.Process.myPid());
    

    About OutOfMemoryError - best place to handle this kind of errors is method Application.onLowMemory(), like:

    @Override
    public void onLowMemory ()
    {
        super.onLowMemory();
        //do smth like freeing reources, etc.
    }
    

提交回复
热议问题