Search code examples
androidstopwatchanti-cheat

How do I prevent auto click cheats in an android app?


I built an android app where the user uses a stopwatch to try to get it to stop on exactly 1 second. There is also a second gamemode where the user tries to start and stop the stopwatch as fast as possible and get the lowest time. There are several auto clicker apps that you can install that will start and stop the stopwatch exactly 1 second apart and also double click the screen within milliseconds.

My question is what is the best way to prevent cheating by this method? Are there libraries designed for this? Thanks for any help!


Solution

  • This question has been answered here.

    Basically, use an API to check for clicks using accessibility services, but you can't straight out block artificial clicks because people who use accessibility features need them. Instead you can measure the time between clicks or the frequency of clicks and block the ones that are 'too perfect'.

    E.g. if someone gets exactly 1 second between clicks 10 times in a row, they're probably cheating. If someone clicks however many times per second at exactly the same timing of 0.X ms between clicks, they're definitely cheating.