Wednesday 15 August 2012

android - Touch event UP being fired when not supposed to, after using "PROXIMITY_SCREEN_OFF_WAKE_LOCK" wakelock -



android - Touch event UP being fired when not supposed to, after using "PROXIMITY_SCREEN_OFF_WAKE_LOCK" wakelock -

i'm having weird issue here. (running on device,motorola xt910 android 4.1.2, xamarin.android 4.16.0)

i have activity button user presses holds record audio. handle ontouch event , hear downwards , events (on downwards start recording, on stop it). far good. now, handle onsensorchanged event in order turn screen off when user holds device ear. accomplish using wakelock this:

private void acquirescreenwakelock() { if (screenwakelock == null) { powermanager pm = (powermanager)getsystemservice (context.powerservice); field = pm.class.getfield ("proximity_screen_off_wake_lock").getint (null); screenwakelock = pm.newwakelock ((wakelockflags)field, "screenwakelock"); } screenwakelock.acquire(); } private void releasescreenwakelock() { if (screenwakelock == null) return; if (screenwakelock.isheld) screenwakelock.release(); }

the problem comes when pressing , holding button record, right after downwards event, receive event without lifting finger... of course of study there other things in between managed narrow problem downwards code (if comment out works expected).

i know i'm using hidden field create wakelock (actually seems it's released in api 21, docs here) haven't found improve way this, , whole screen off/on process works flawlessly. i'm having issue while testing on motorola xt910 running android 4.1.2, i've tested on moto g running android 4.4.4 , works fine there (no events beingness fired when holding downwards button).

i'm @ loss here figuring out...how can wakelock cause behaviour? have other way turn screen off/on? i've searched other posts none seemed help me. using partial wakelock doesn't work either (i've checked code). in advance!

p.s: i've checked , touch event beingness registered once.

proximity_screen_off_wake_lock turns screen off/on according proximity state itself. no need handle onsensorchanged event. might cause issue.

android xamarin ontouchevent wakelock proximity

No comments:

Post a Comment