1

I need to disable the touch of my android device when my app is running.

Currently I am using

getWindow().setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE)

But when call or other app notifications comes, they are touchable. I want to disable all touches.

Please help me if anybody have such solution.

I want to enable again the touch by power key action.

Vikasdeep Singh
  • 20,983
  • 15
  • 78
  • 104
Alex king
  • 11
  • 2

2 Answers2

0

You could create a floating View that covers all the screen and that stay as an Overlay over all other things, and then set it as NOT_FOCUSABLE (neither _IN_TOUCHMODE) and NOT_TOUCHABLE, but this solution could not work.

The other solution requires Root: you have to directly open the correct touchscreen "/dev/input/eventX" STREAM (you have to analize its ABSInfos to recognize the touchscreen device) for EXCLUSIVE access and then consume all the Events until you release the esclusive_lock.

emandt
  • 2,547
  • 2
  • 16
  • 20
  • I have to make an app for doing these task,no root or anything – Alex king Aug 23 '18 at 00:26
  • So you are relegated to the First suggestion, but it could not work for all visual things (maybe some Alertdialog or similar things). This is a limited think because an App cannot ruins the user' experience of the whole System, so there isn't any official and easy way to do it. – emandt Aug 23 '18 at 00:32
0

You can not do this and you should not even try this. You can not disable the touch of device. It is against the ethics. Android will not allow to do this and should not allow.

You can only disable touch for your application only but not for other apps and System UIs.

If Android platform will allow such feature/API, nobody will buy Android phone.

Hope this will help you and others as well.

Vikasdeep Singh
  • 20,983
  • 15
  • 78
  • 104
  • "It is against the ethics." Did Android team know that multiple activities will be launched after user clicks the same button/item multiple times? The whole design of Android is against the ethics. – Kimi Chiu Feb 16 '20 at 04:14