[英]Android calling onCreate() after finish() when in landscape
I have an activity that starts the Vibrator system service in its onCreate method, then when the user pushes a button it cancels the vibrator, then calls finish() to close the activity. 我有一个活动,该活动以其onCreate方法启动“振动器”系统服务,然后当用户按下按钮时,它取消了振动器,然后调用finish()关闭该活动。
This activity is brought up via the AlarmManager, so when it gets closed it will return the user to whatever app they currently had open (not necessarily mine). 该活动是通过AlarmManager引发的,因此当它关闭时,它将使用户返回到他们当前打开的任何应用程序(不一定是我打开的)。
The problem I'm having is if my activity is in landscape mode, and the user is brought to a screen that doesn't support landscape (such as the home screen) when the activity closes, my application switches to portrait and calls onCreate() before actually closing my screen. 我遇到的问题是,如果我的活动处于横向模式,并且在活动关闭时用户被带到不支持横向的屏幕(例如主屏幕),我的应用程序将切换为纵向并调用onCreate( ),然后再实际关闭屏幕。 So the steps causing this problem are as follows... 因此,导致此问题的步骤如下...
Currently the only way I can think of to rectify this is to make my activity only support portrait mode, but I'd like to avoid that if I can. 目前,我想纠正这一问题的唯一方法是使我的活动仅支持人像模式,但我想避免这种情况。 Does anyone know a way in which I can prevent onCreate() from being called after I call finish()? 有谁知道我可以在调用finish()之后阻止onCreate()的方法吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.