[英]Why does my Android app stops, when I move it to the background?
I'm developing an Android application and I have the following code lines: 我正在开发一个Android应用程序,并且具有以下代码行:
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_HOME) {
moveTaskToBack(true);
return true;
}
[... SOME MORE CODE ...]
}
When I test it on the emulator, it works perfectly and it closes the app and opens it at the some point as before. 当我在模拟器上对其进行测试时,它可以完美运行,并且可以关闭该应用程序,并像以前一样在某个时候打开它。 But when I load the APK on a real device, it always stops the application and starts it new, when I open it again.
但是,当我在真实设备上加载APK时,当我再次打开它时,它总是会停止应用程序并重新启动它。 With the loading screen.
随着加载屏幕。
Where is the problem? 问题出在哪儿?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.