Skip to main content

Posts

Showing posts with the label Kotlin

How to Programmatically Route Users to AutoStart Settings on Xiaomi

  Background processing on Android is a well-documented architectural challenge, but Xiaomi's custom Android skins (MIUI and the newer HyperOS) take aggressive task-killing to another level. If your application relies on   WorkManager , foreground services, or push notifications, you have likely encountered the silent termination of your background processes. To preserve battery life, Xiaomi devices require users to explicitly whitelist applications in a proprietary "AutoStart" menu. Because developers cannot enable AutoStart via API, they must use explicit Intents to deep-link users to the correct, highly-fragmented MIUI settings screens. This article details the mechanics of Android intent routing required to navigate users directly to the correct permission screens, bypassing the inaccessible MIUI permissions API. The Root Cause: Why Standard APIs Fail Android's core philosophy historically allowed apps to start automatically on boot by declaring the  RECEIVE_BOOT_...

Why Android SMS Retriever API Fails on MIUI (And How to Fix It)

  Implementing seamless OTP auto verification is a baseline requirement for high-conversion onboarding flows, particularly in FinTech applications. While standard implementation of the Google Play Services SMS Retriever API operates predictably on Pixel and Samsung devices, it exhibits a notorious, silent failure rate on Xiaomi, Redmi, and Poco devices running MIUI or HyperOS. Instead of automatically capturing the one-time password, the application hangs waiting for a broadcast that never arrives, ultimately resulting in a 5-minute timeout. This architectural bottleneck directly impacts user activation metrics. This article dissects the root cause of this OEM-specific interference and provides a production-ready Kotlin implementation to bypass it. The Root Cause: MIUI's Custom Permission Architecture Under normal circumstances, the Android SMS Retriever API operates without requiring the sensitive  READ_SMS  permission. Play Services listens for incoming SMS messages con...