Solving Drunk Texting with Android Accessibility Services
Building Drinking Mode taught me more about Android's Accessibility APIs than any tutorial ever could. Here's the technical story of how I built an app that blocks messaging when you're drinking — and the ethical questions that came with it.
The Problem
Drunk texting is a universal problem. Studies suggest that roughly 40-50% of smartphone users have sent messages they regretted while under the influence. The consequences range from mild embarrassment to damaged relationships and professional repercussions.
Existing solutions were either too easy to bypass (a simple "Are you sure?" dialog) or too aggressive (locking the entire phone). I wanted something in between — block messaging apps specifically, but make it hard to disable while impaired.
Android Accessibility Services
Android's Accessibility Service API was designed to help users with disabilities interact with their devices. It provides powerful capabilities: monitoring which app is in the foreground, reading screen content, performing gestures, and overlaying UI elements.
For Drinking Mode, I use a subset of these capabilities — specifically, detecting when a blocked messaging app comes to the foreground and overlaying a blocking screen. The service runs in the background and monitors app transitions in real-time.
The Implementation
The core logic is surprisingly simple:
- Register an AccessibilityService that listens for TYPE_WINDOW_STATE_CHANGED events
- When an event fires, check the package name against a list of blocked apps
- If blocked, launch a full-screen activity that overlays the messaging app
- The overlay shows a warning and requires solving a challenge to dismiss
The "challenge" is key to the design. It needs to be easy for a sober person but hard for someone who's had a few drinks. I tested several approaches: complex math problems, typing a sentence backwards, and pattern recognition. The math approach worked best — solving "347 × 28 = ?" is trivial with a clear head but nearly impossible after several drinks.
Google Play Policy Challenges
Google has strict policies about Accessibility Service usage. Apps must clearly disclose why they need accessibility access, and the service can only be used for accessibility-related purposes. I had to carefully document that Drinking Mode uses accessibility to help users avoid harmful behavior — which is a legitimate accessibility use case.
The app was initially rejected during review. After a detailed appeal explaining the use case and providing evidence that the accessibility service is used minimally (only foreground app detection, no content reading), it was approved.
Ethical Considerations
Building an app that restricts user behavior raises important ethical questions. Who decides when someone "shouldn't" be texting? What if there's an emergency? What about personal autonomy?
My approach was to make everything opt-in and user-controlled. You choose to activate Drinking Mode. You choose which apps to block. Emergency calls are always allowed. And you can always deactivate it — it's just harder when you're impaired, which is the whole point.
The ethical framework is simple: the sober version of you makes the decision to restrict the drunk version of you. It's not the app making choices for you — it's you making choices for your future self.
Results and Impact
The response from users has been overwhelmingly positive. The most common feedback is "I wish I had this app last weekend." People genuinely appreciate having a tool that helps them avoid regrettable decisions without feeling patronized.
The technical lesson is broader: Accessibility Services are incredibly powerful tools that can be used for creative purposes beyond their original intent. The key is to use them responsibly, transparently, and in ways that genuinely help users.