skip to Main Content

Android Studio – How to make broadcastreceiver work on MIUI when phone is asleep?

class AlarmReceiver : BroadcastReceiver() { override fun onReceive(context: Context, intent: Intent) { Toast.makeText(context,"Ready to wake up?", Toast.LENGTH_LONG).show() val myIntent = Intent(context,AlarmActivity::class.java) myIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK) context.startActivity(myIntent) } } Manifest: <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/Theme.QuickNap"> <activity android:name=".AlarmActivity" android:screenOrientation="portrait" android:theme="@style/Theme.NoActioBar" android:windowSoftInputMode="adjustResize"></activity> <!-- <receiver-->…

VIEW QUESTION
Back To Top
Search