I developed an Android app called Multi Countdown Timer In which we can start multiple timers at once. The App runs on the background using Foreground Service in order to run continuously and override's The Android Doze Mode.
I have tested my App on Samsung s6, A7, Nokia 3.1, LG Nexus 5x and some emulators. The Apps runs perfectly and Wake Up's when the timer finished. But on the other hand, whenever I run my App on Huawei Devices (EMUI 8 Android Oreo 8.0.0) the result is not satisfactory at all. The problem I'm facing is that the App didn't wake up the screen when the Timer is Finished and when the timer is finished when I open my device it rings then but didn't auto Wake Up the screen as it is working on the other devices.
I have replicated this App Multi Timer StopWatch and this App is working fine even on Huawei Devices.
This is my Activity in Manifest.xml.
android:name=".view.alarm.AlarmActivity"
android:process="alarm.process"
android:screenOrientation="portrait"
android:showOnLockScreen="true"
android:showWhenLocked="true"
android:turnScreenOn="true"
android:theme="@style/splashScreenTheme" />
This is how I called my Alarm Activity.
val alarmIntent = Intent(this@CountDownTimerForegroundService, AlarmActivity::class.java)
alarmIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
alarmIntent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
alarmIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT)
}
alarmIntent.putExtra(ALARM_PASSING_ID, timerObj.id)
startActivity(alarmIntent)
And this is my Alarm Activity onCreate
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
window.addFlags(
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
or WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
or WindowManager.LayoutParams.FLAG_FULLSCREEN
or WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
or WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
or WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
or WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON
)
setContentView(R.layout.activity_alarm)
Any Help will be highly appreciated. Thanks in Advance.
Update:
1) On Huawei device, I have tested after Whitelisting my app in PowerManager and also enabled Battery Optimization But it also didn't help out.
2) I have tested with some Wake Locks in my Foreground Service but still getting the same behavior.
3) Used Android AlarmManager with setExactAndAllowWhileIdle still didn't wake up the device.
4) Used Don'tKillMyApp Solution to use LocationManagerService Tag in Wake Lock also didn't help out.