1

The App currently runs in IMMERSIVE_STICKY mode, but when user swipes from the side - OS shows menu and home/back buttons. So user can turn my app off or run some other stuff which is unacceptable. Therefore, I need to disable touchscreen device completely on android to prevent any taps and swipes.

If i cant disable it via official API, can i disable touchpad using console? Android will be rooted.

I found that my touchpad device is /sys/devices/virtual/input/input1 but still cant find where can I disable it. /power/control takes only 'on' or 'auto'.

I found other solution with xinput but on android there is no one.

Vlad
  • 21
  • 6
  • This is not acceptable, you can't force the user to use only your app. Android os have multitasking feature, so user can switch between multiple apps. And btw you can't turn off the screen touch completely even if your phone is rooted. – Onkar Nene Jul 13 '16 at 12:57
  • There's no way to make your application take exclusive control of a general-purpose Android host. If this is your own hardware and your own Android image, then of course you can set everything up to run just one application exclusively - but this is controlled from outside of your application and belongs in system configuration! – Kuba hasn't forgotten Monica Jul 13 '16 at 21:44
  • Did you resolve this issue ? I have the same need to disable touch screen .thx, – ransh Nov 28 '16 at 09:09
  • @ransh No I couldnt find how to disable touchpad. Instead I decided to block status bar only. http://stackoverflow.com/questions/7457730/preventing-status-bar-expansion Also to block "main" and "recent" buttons you can override onPause method and restore your app there using moveTaskToFront and KeyguargManager. It doesn't work as intended on some devices (for example android 4.~ by sony), but works well on most. – Vlad Nov 29 '16 at 10:41

1 Answers1

2

I think you can override the function onTouchEvent.

private boolean touch_disabled=true;
@Override
public boolean onTouchEvent(MotionEvent e) {
        if (touch_disabled){
            return true;
        }else {
            //do something here if your touch screen is activated
        }
    }
    public disable_touch(boolean b) {
        touch_disabled=b; //function to activate or desactivate touch screen
    }
  • Overriding touch event makes your app ignore touch event, not the system. So menu and buttons still appear. – Vlad Jul 13 '16 at 13:13
  • @Vlad Unfortunately, it's impossible to override some systems events. It's for some evident security reasons. There are some apps who purpose to lock touch screen like touch lock but i don't how they works. – Florian Bury Jul 13 '16 at 13:24