0

I have a simple app, that uses a AlarmManager and a BroadcastReceiver, nothing complicated, the onReceive() displays a toast. For those who dont have a Xiaomi, here is what the screen looks like:

enter image description here

If I swipe the app away, the Receiver method is not called at all, no Toast, no Logs. If I click on the (x) on the bottom side, which kills all the opened apps, everything works flawlessly. Toast displayed, Log written.

I have been trying to solve this problem for two days, with no success, so thats why I turn to You now, as I have no idea why is this happening.

I have overriden every on...() method in the main activity, to check the lifecycle of the app, it looks like this I click on the icon:

onApplyThemeResource
onCreate
onAttachFragment
onWindowAttributesChanged
onWindowAttributesChanged
onWindowAttributesChanged
onWindowAttributesChanged
onWindowAttributesChanged
onCreateView
onCreateView
onCreateView
onCreateView
onCreateView
onCreateView
onWindowAttributesChanged
onCreateView
onCreateView
onCreateView
onCreateView
onCreateView
onCreateView
onCreateView
onCreateView
onCreateView
onCreateView
onCreateView
onCreateView
onContentChanged
onStart
onPostCreate
onWindowAttributesChanged
onStateNotSaved
onResume
onResume
onResumeFragments
onEnterAnimationComplete
onAttachedToWindow
onCreatePanelView
onCreatePanelMenu
onCreateOptionsMenu
onPreparePanel
onPrepareOptionsMenu
onWindowFocusChanged

And if I kill it by (x) or swiping it away

onWindowFocusChanged
onUserInteraction
onUserLeaveHint
onPause
onCreateDescription
onSaveInstanceState
onTrimMemory

Any help will be greatly appriciated. I did not include the code, because I think the issue is with the phone. On emulator it works fine. Unfortunately I don't have another phone to try it.

Mark
  • 56
  • 5
  • Those little chinese are watching you (joke). They had some changes under the hood and added more logs. Should be a normal behaviour when you kill an app. – Cătălin Florescu Apr 08 '18 at 17:34
  • I'm dealing with the same issue too. The alarm is not waking up when the app is killed (swiped away). The only way to make it work is by adding the app to 'Auto Start' and remove Battery Optimization. But that is not a satisfactory answer to me. – Srikar Reddy Apr 09 '18 at 04:50
  • This works for me too, but I don't think either that this is a good solution. The funny thing is, when closed by th X in the bottom, everything works – Mark Apr 09 '18 at 10:04

0 Answers0