Engineering

Mapping Product Success: Haptic Design in Prayer Apps

A technical deep-dive into using Android’s Haptic Feedback API to create non-visual, tactile cues for prayer times and mindful transitions.

Amin Shekh · October 15, 2026
Share

Visual and auditory notifications often compete for a user’s limited attention, frequently leading to notification fatigue or accidental dismissal. In the context of a prayer time app like Salah Companion: Prayer Times, the goal isn't just to grab attention, but to facilitate a transition from a busy state of mind to a spiritual one. Haptic feedback—the use of tactile sensations to communicate information—offers a unique, non-intrusive way to signal these transitions. By leveraging the Android Haptic Feedback API, we can create a sophisticated language of vibration that tells a user which prayer time has arrived or how much time remains before a transition, all without them needing to look at their screen or disturb those around them with an audible alarm.

The Engineering Case for Haptic Specificity

Most Android applications treat vibration as a binary state: it is either on or off. When a notification arrives, the motor spins at a default intensity for a set duration. However, modern Android devices, particularly those with high-quality linear resonant actuators (LRAs), are capable of much more. They can produce distinct sensations that vary in sharpness, duration, and rhythm.

In our development of Mindful Assistant, we found that haptic feedback serves as a "cognitive tap." Just as a friend might tap your shoulder differently to get your attention versus warning you of a hazard, an app should vary its tactile output based on the urgency and nature of the event. For a prayer app, the tactile signature for Fajr (dawn) should feel fundamentally different from the signature for Asr (afternoon).

The Haptic Feedback API vs. VibrationEffect

To implement this, developers must choose between the legacy Vibrator service and the more modern VibrationEffect API introduced in Android 8.0 (API 26) and expanded in later versions. While the HapticFeedbackConstants are useful for standard UI interactions like long presses or keyboard taps, custom patterns require VibrationEffect.

  • HapticFeedbackConstants: Best for immediate UI confirmation (e.g., CONFIRM, REJECT, GESTURE_START). These are system-managed and ensure consistency across the OS.
  • VibrationEffect: Best for custom notification signatures. It allows for createWaveform and createPredefined (in API 29+), which enable nuanced pulses rather than just a continuous buzz.

Designing the Haptic Language

When we design for touch, we are mapping physical sensations to abstract concepts. For prayer timings, we categorize these into three distinct haptic profiles:

  1. 1.The Gentle Nudge (Pre-Adhan): A soft, low-amplitude pulse meant to signal that a prayer time is 10 minutes away. This helps the user wrap up current tasks.
  2. 2.The Primary Signal (Adhan Time): A clear, rhythmic sequence that identifies the specific prayer.
  3. 3.The Completion Pulse (Post-Prayer Tracker): A short, sharp "tick" to confirm a prayer has been logged in the tracker.

Comparison of Haptic Signatures

Event TypeHaptic Pattern (VibrationEffect)User Perception
Pre-Prayer Warninglong[] {0, 50, 200, 50}A subtle double-tap, like a heartbeat.
Fajr (Dawn)createWaveform(new long[]{0, 300}, new int[]{100}, -1)A long, gradual swell that feels calm.
Maghrib (Sunset)createWaveform(new long[]{0, 100, 50, 100}, new int[]{255, 0, 255}, -1)Two sharp, energetic bursts signaling a shift.
Logging a PrayerVibrationEffect.EFFECT_CLICKA satisfying, mechanical-feeling snap.

Implementation: Creating Custom Waveforms

To implement these patterns effectively, you must handle the various API levels to ensure the app doesn't crash on older devices while still taking advantage of newer hardware. Below is a simplified example of how we structure a haptic manager for a productivity context.

```java public void triggerPrayerHaptic(Context context, String prayerName) { Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE); if (vibrator == null || !vibrator.hasVibrator()) return;

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { VibrationEffect effect; if (prayerName.equals("Fajr")) { // A soft, ramping start effect = VibrationEffect.createWaveform(new long[]{0, 500}, new int[]{0, 150}, -1); } else { // A standard double pulse effect = VibrationEffect.createWaveform(new long[]{0, 100, 100, 100}, -1); } vibrator.vibrate(effect); } else { // Fallback for older devices vibrator.vibrate(200); } } ```

One technical hurdle discussed in our article on making Android notifications actually reliable is ensuring these triggers execute even when the phone is in Doze mode. For haptics attached to notifications, the vibration must be defined within the NotificationChannel. However, for in-app cues—like the rhythmic pulses in Mindful Assistant—direct control via the Vibrator service is necessary.

Geographic and Environmental Context

"Geographic haptics" refers to the adjustment of tactile intensity based on the user's environment or movement. While we haven't fully automated this, the design principle is sound: a phone in a pocket needs a higher amplitude than a phone sitting on a wooden desk.

In Salah Companion, we allow users to choose "Tactile Profiles." A "Pocket" profile uses high-amplitude, short-duration pulses to cut through fabric and movement. A "Desk" profile uses low-amplitude, longer-duration pulses to prevent the phone from rattling loudly against a hard surface. This level of detail transforms a generic utility into a polished tool that respects the user’s physical environment.

The Importance of Amplitude Mapping

In API 26+, the ability to control amplitude (int values from 1-255) is the most significant tool for haptic design. Instead of a simple ON duration, we can create a "fade-in" effect. This is particularly useful for prayer times, where a sudden, violent vibration might be jarring during a quiet moment. By starting the amplitude at 0 and ramping to 150 over 500 milliseconds, the motor begins to spin softly before reaching its full signaled strength.

Accessibility and Inclusive Design

Beyond aesthetics, sophisticated haptics are a core component of accessibility. For users with visual impairments, a distinct haptic pattern for each prayer time provides essential information that a screen reader might deliver too slowly.

We apply similar logic in ShariahSignal when displaying stock verdicts. While the UI uses color coding (Green for Compliant, Red for Non-Compliant), a haptic "Double-Click" for compliance and a "Long Pulse" for non-compliance ensures that the user receives the verdict through multiple sensory channels. This redundancy reduces errors and increases the user's confidence in the data provided.

Testing Haptic Patterns

Testing haptics is notoriously difficult because you cannot "see" the output in a logcat. It requires physical device testing across multiple hardware generations.

  1. 1.LRA vs. ERM: Older or cheaper devices use Eccentric Rotating Mass (ERM) motors, which have a "spin-up" and "spin-down" time, making them feel "mushy." Newer flagship devices use Linear Resonant Actuators (LRA), which can start and stop almost instantly. Your patterns must be tested on both to ensure the "Double-Tap" doesn't just feel like one long buzz on an ERM motor.
  2. 2.Surface Testing: Test the vibration on a hard table, a soft mousepad, and inside a trouser pocket. A pattern that feels great in your hand might be inaudible in a bag.
  3. 3.User Association: In our internal testing, we found that users could distinguish between a maximum of three different rhythmic patterns before they became confused. We suggest limiting specific haptic "identities" to the most critical events (like the start of a prayer) while using generic pulses for secondary actions.

Final Design Considerations

Integrating haptics should never be an afterthought. It should be documented alongside your visual design system. If you define a primary brand color, you should also define a primary "brand pulse." This consistency helps users build a mental model of your app's behavior, leading to a more intuitive experience.

For further reading on how we manage the underlying logic that triggers these events, see our guide on Exact Alarms vs. Periodic Work.

What to do next

  1. 1.Audit your current notifications: Identify one notification in your app that currently uses the default vibration and replace it with a custom VibrationEffect that matches the "weight" of the alert.
  2. 2.Implement Amplitude Ramping: Use the createWaveform method to add a 200ms ramp-up to your primary alerts to make them feel more premium and less jarring.
  3. 3.Create a Haptic Toggle: Always provide a way for users to disable or simplify haptics in the settings menu, as tactile sensitivity varies greatly between individuals.
#android#haptics#ux design#engineering

One email per launch. No spam, unsubscribe any time.