Reputation: 2114
I extend Cocos2dxActivity, and in the onCreate, I am showing a DialogFragment with some GDPR stuff in it. The only lifecycle events that my custom DialogFragment overrides is onSaveInstanceState() and onCreateDialog(). My dialog does have a button.requestFocus when it starts.
If the phone screen is locked while the app is starting, all touch events will be cancelled.
W/ViewRootImpl[GDPR Dialog Title]: Dropping event due to no window focus: MotionEvent { action=ACTION_DOWN, ...
W/ViewRootImpl[GDPR Dialog Title]: Cancelling event due to no window focus: MotionEvent { action=ACTION_CANCEL, ...
As well as
Cancelling event due to no window focus: KeyEvent { action=ACTION_UP, keyCode=KEYCODE_VOLUME_DOWN, ...
If I don't show the dialog, I cannot reproduce the bug.
If the app does not have cocos, I cannot reproduce the bug.
Locking the phone after the app has started does not reproduce the bug.
Moving the code that shows the dialog into onStart() or onResume() doesn't change anything.
I've tried commenting out different parts of Cocos2dxActivity's onResume() and onPause() and forcing the resume code to run even if cocos does not have focus, but that didn't change anything either.
Here is a trimmed down logcat with only the stuff that seems relevant to this issue
[App Starts]
D/Cocos2dxActivity: onResume()
D/AudioFocusManager: requestAudioFocus succeed
[Phone is locked while app is starting]
D/Cocos2dxActivity: onPause()
D/AudioFocusManager: abandonAudioFocus succeed!
[Phone is unlocked]
D/Cocos2dxActivity: onWindowFocusChanged() hasFocus=true
D/Cocos2dxActivity: onResume()
D/AudioFocusManager: requestAudioFocus succeed
D/Cocos2dxActivity: onWindowFocusChanged() hasFocus=false
W/ViewRootImpl[GDPR Dialog Title]: Dropping event due to no window focus: MotionEvent { action=ACTION_DOWN, ...
Upvotes: 1
Views: 85