Titanium JIRA Archive
Appcelerator Community (AC)

[AC-2383] Android: Services in background not working when phone enter in sleep mode

GitHub Issuen/a
Resolution Date2013-04-01T23:24:00.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
Labelsandroid, background, service
AssigneeDaniel Sefton


In a simple alarm clock it´s impossible to get a background service running every 5 seconds, because when phone enter in sleep mode, the service stops running (maybe the internal counter of interval stops) not vibrate, not counter, nothing. Then when wake up the phone, service restart, but it´s not usable. For example: in app.js:
var intent = Ti.Android.createServiceIntent({
    url: 'service.js'
intent.putExtra('interval', 5000);
in service.js:
Ti.API.info('Alarm control');
Ti.Media.vibrate([ 0, 100]);
in tiapp.xml:
<android xmlns:android="http://schemas.android.com/apk/res/android">
  <manifest android:versionName="1.0.0">
      <uses-permission android:name="android.permission.WAKE_LOCK"/>
      <uses-permission android:name="android.permission.VIBRATE"/>
    <service url="service.js" type="interval"/>
If needed (help) I could provide complete titanium project. Thanks! Regards.


  1. Anirudh Nagesh 2012-11-20

  2. juanra 2012-11-26

    Hello Anirudh!! Thanks for your answer. I allways used SDK 2.1.2GA, and now I have tested my code in 3.0. The error persist. I have look at the ticket but really it´s not the same problem, in that ticket the problem is that the service it´s killed when exit application. In my case the service do nothing (not running) when the phone enter in sleep mode. I know that many people have same problem. in the case of my example, the phone stops vibrating when the screen go black. I have researched about that and it seems than the solution in android it´s about AlarmManager, it provides tools for wake up the phone in certain moments. Thanks a lot!

JSON Source