0

Hello I've a basically simple question to ask, what happens to the android OS when my smartphone's screen goes off ? I've noticed a couple of misleading behaviours into my application like :

  • When screen is off I cannot anymore get results from bluetooth scan, it's like there are no more active devices around me while actually there are like 3-4.

  • When screen is off most of the times I cannot send or receive messages from other devices via bluetooth.

As soon as I turn the screen on everything start to work fine again, then I turn off the screen again and after like 5-10 my phone stops working properly. I don't have anything inside the onPause method.

Is there somekind of trigger that get fired every X minutes that leads the devices into sleep/hibernate mode?

EDIT :

I decided to call every X min a full wake lock but for some reason my application started to behave weirdly. Yesterday I noticed that the system killed on purpose my application calling the onDestroy() method. Is this even possible? I mean my application uses like 32 MB of RAM and on my test phones I have like hundreds MB of free memory.

In another case the system closed my app and restarted it, how can this happen?

Vittorio Cozzolino
  • 931
  • 1
  • 14
  • 31

1 Answers1

0

Sometime after the screen turns off, based on user settings for inactivity.

CPU might sleep and threads might suspend..

so you WAKE_LOCK or AlarmManager ...

AlarmManager has a method to setRepeating Alarm every X seconds

Michael Shrestha
  • 2,547
  • 19
  • 30
  • Thank you for your answer. Actually I'm using a wakelock that it is correctly fired every X seconds. The problem is that sometimes even if I call it, the system do not responds properly. So I thought that there is some sort of "big sleep" fired after long time that brings down everything no matter if you try to wake up the CPU. – Vittorio Cozzolino Jun 24 '13 at 10:32
  • are u using partial wake lock ? – Michael Shrestha Jun 24 '13 at 10:38
  • 2
    check this answer might help u http://stackoverflow.com/questions/14741612/android-wake-up-and-unlock-device – Michael Shrestha Jun 24 '13 at 10:38
  • Yes I'm using a partial wake lock. I will look into your link, thank you :) – Vittorio Cozzolino Jun 24 '13 at 10:42