onPause() Android

╄→尐↘猪︶ㄣ 提交于 2019-12-04 19:03:01
Fernando Miguélez

You should use onStop() instead of onPause(), which is called whenever the activity is not shown on screen but is still running, i.e. when the screen goes black. Instead of overwriting onKeyDown() it is better to use onBackPressed() method, however if you place your current code of onPause() inside onStop() it would not be required to overwrite it.

stefan bachert

The only way I see it is to derive a new class from Activity supporting your library. But this approach will run into a permutational explosion. Any specialist standard activity needs a MyLib-variant too. (ListActivity, FragmentActivity, and so on)

class MyLibActivity extends Activity {
    @Override
    public void onPause() ..

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event)..

}

So it's probably the best to offer just a support for the pure activity.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!