在返回按钮事件背景的移动应用程序 [英] Moving application in background on back button event
本文介绍了在返回按钮事件背景的移动应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有可能在移动后台应用程序时,我们的Android点击设备后退按钮?
Is it possible to move the app in background when we click on device back button in android?
背景从那里启动意味着应用程序移动到屏幕(应用程序)?
background means application moves to screen(application) from where it launches ?
推荐答案
我将preFER使用低于code键移动在后台应用
I will prefer to use below code to move application in background
@Override
public boolean onKeyDown(int keyCode, KeyEvent event)
{
switch(keyCode)
{
case KeyEvent.KEYCODE_BACK:
if(isTaskRoot()) {
Intent homeIntent = new Intent(Intent.ACTION_MAIN);
homeIntent.addCategory(Intent.CATEGORY_HOME);
homeIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(homeIntent);
return true;
}
else {
super.keyDown(keyCode,event);
return false;
}
default:
super.keyDown(keyCode,event);
return false;
}
}
这篇关于在返回按钮事件背景的移动应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文