{ "id": "63918", "key": "TIMOB-3286", "fields": { "issuetype": { "id": "2", "description": "A new feature of the product, which has yet to be developed.", "name": "New Feature", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [ { "id": "12096", "description": "", "name": "Sprint 2012-04", "archived": true, "released": true, "releaseDate": "2012-02-26" }, { "id": "12593", "name": "Release 2.0.0", "archived": false, "released": true, "releaseDate": "2012-03-30" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2012-02-17T15:06:10.000+0000", "created": "2011-04-15T03:41:19.000+0000", "priority": { "name": "High", "id": "2" }, "labels": [], "versions": [ { "id": "11244", "name": "Release 1.7.0", "archived": true, "released": true, "releaseDate": "2011-06-13" } ], "issuelinks": [], "assignee": { "name": "billdawson", "key": "billdawson", "displayName": "Bill Dawson", "active": true, "timeZone": "Europe/Berlin" }, "updated": "2017-03-24T20:51:40.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10202", "name": "Android", "description": "Android Platform" } ], "description": "{html}

Is it possible to add support for the constants for services for\r\nbetter control over the instances through Ti.Android.Service and\r\nthe start event handler?

\r\n

I'm finding my Android background service is getting cleared up\r\nwhen the device is running low on memory. I guess the alternative\r\nis support for foreground services.

\r\n

Android Docs: \r\nhttp://developer.android.com/reference/android/app/Service.html#STA...
\r\nQA Thread: \r\nhttp://developer.appcelerator.com/question/116757/creating-services...

{html}", "attachment": [ { "id": "25786", "filename": "timob3286.zip", "author": { "name": "billdawson", "key": "billdawson", "displayName": "Bill Dawson", "active": true, "timeZone": "Europe/Berlin" }, "created": "2012-02-15T13:17:59.000+0000", "size": 2320728, "mimeType": "application/zip" } ], "flagged": false, "summary": "Android: Support service constants", "creator": { "name": "marke", "key": "marke", "displayName": "MarkE", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "marke", "key": "marke", "displayName": "MarkE", "active": true, "timeZone": "America/Los_Angeles" }, "environment": null, "comment": { "comments": [ { "id": "164516", "author": { "name": "bmd2k1", "key": "bmd2k1", "displayName": "Brian Dittmer", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Really need to have support for Android Service StartForeground method.", "updateAuthor": { "name": "bmd2k1", "key": "bmd2k1", "displayName": "Brian Dittmer", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-08-30T09:43:20.000+0000", "updated": "2011-08-30T09:43:20.000+0000" }, { "id": "164771", "author": { "name": "bmd2k1", "key": "bmd2k1", "displayName": "Brian Dittmer", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Meant to include this link \r\nhttp://developer.android.com/reference/android/app/Service.html#startForeground(int, android.app.Notification)", "updateAuthor": { "name": "bmd2k1", "key": "bmd2k1", "displayName": "Brian Dittmer", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-09-01T10:06:59.000+0000", "updated": "2011-09-01T10:06:59.000+0000" }, { "id": "183282", "author": { "name": "billdawson", "key": "billdawson", "displayName": "Bill Dawson", "active": true, "timeZone": "Europe/Berlin" }, "body": "h3. Testing Notes\r\n\r\n\r\n* Unzip the attached timob3286.zip and import it into Titanium Studio.\r\n\r\n* Run the app *on an Emulator* (because we're going to do some stuff in {{adb}} that you're non-rooted phone probably won't allow.)\r\n\r\n* Go to Terminal (command prompt, whatevs) and enter {{adb logcat}}.\r\n\r\n* You should see messages such as \"hello from inside the service JS code\" passing by. This is a {{Ti.API.info}} message from inside the test service's Javascript (testservice.js).\r\n\r\n* Now do {{adb shell ps}} in Terminal. You'll see a list of processes running on the emulator. Find com.billdawson.timob3286 and note its PID. It's typically the number in the second column, like here it's 485:\r\n\r\n{code}\r\napp_38 485 33 105004 31400 ffffffff afd0c51c S com.billdawson.timob3286\r\n{code}\r\n\r\n* Now do {{adb shell \"kill -2 PID\"}} in Terminal, but replace PID with the number you got in the previous step. E.g.,\r\n\r\n{code}\r\nadb shell \"kill -2 485\"\r\n{code}\r\n\r\n* Real quick do {{adb logcat}} again and look at the logcat output. Now you should see indications that the application was killed, plus an indication that the system will restart the Service that was running in the application. It will tell you how many milliseconds will elapse before it tries to restart the service. Example:\r\n\r\n{code}\r\nI/ActivityManager( 61): Force stopping package com.billdawson.timob3286 uid=10038\r\nW/ActivityManager( 61): Scheduling restart of crashed service com.billdawson.timob3286/.TestserviceService in 5000ms\r\n{code}\r\n\r\n* The example above shows that Android will restart the service in about 5 seconds. You should see something similar (warning: sometimes Android hikes this number up considerably, like up to 5 _minutes_).\r\n\r\n* Sit there and wait until the time has elapsed, keeping your eye on logcat output.\r\n\r\n* When the time elapses, the logcat output should show you that the service has been restarted. You should start seeing the \"hello from inside the service JS code\" messages fly by again.\r\n\r\nSo the above steps, if successful, prove that {{startMode: Ti.Android.START_REDELIVER_INTENT}} functions correctly (you'll see that line in app.js). That constant means \"if I get killed, then restart me, and when you restart me, send me again the Intent that originally started me.\"\r\n\r\nNow you need to test two more variants:\r\n\r\na) Change app.js by removing {{startMode: Ti.Android.START_REDELIVER_INTENT}} and re-installing, re-running the app. Follow the steps above. The behavior should be the same (the milliseconds until restart may change -- Android seems to randomize that.) This proves that {{START_REDELIVER_INTENT}} is the default behavior, so if you don't specify {{startMode}} it will behave as though you did specify {{START_REDELIVER_INTENT}}.\r\n\r\nb) Change app.js again, this time put {{startMode: Ti.Android.START_NOT_STICKY}}, then re-install and re-run the app. Follow the steps above. *However*, this time the service should *not* restart. (Even if Android says it's scheduling the restart of the service, when the time elapses it should not, in fact, be restarted.) {{START_NOT_STICKY}} is your way of telling Android, \"Hey, if you decide to kill me off to save memory, that's okay, and you don't even need to restart me later, I'm totally cool with that, muchacho.\"\r\n", "updateAuthor": { "name": "billdawson", "key": "billdawson", "displayName": "Bill Dawson", "active": true, "timeZone": "Europe/Berlin" }, "created": "2012-02-15T14:17:50.000+0000", "updated": "2012-02-15T14:17:50.000+0000" }, { "id": "183283", "author": { "name": "billdawson", "key": "billdawson", "displayName": "Bill Dawson", "active": true, "timeZone": "Europe/Berlin" }, "body": "Pull request ready:\r\n\r\nhttps://github.com/appcelerator/titanium_mobile/pull/1433", "updateAuthor": { "name": "billdawson", "key": "billdawson", "displayName": "Bill Dawson", "active": true, "timeZone": "Europe/Berlin" }, "created": "2012-02-15T14:22:54.000+0000", "updated": "2012-02-15T14:22:54.000+0000" }, { "id": "288888", "author": { "name": "michael", "key": "michael", "displayName": "Michael Gangolf", "active": true, "timeZone": "Europe/Berlin" }, "body": "i'm testing the REDELIVER_INTENT example with 3.2.0 and receive the following log:\r\n\r\n{code} \r\n01-20 22:43:13.368: I/TiAPI(17954): hello from _inside_ the service JS code\r\n01-20 22:43:18.353: I/TiAPI(17954): hello from _inside_ the service JS code\r\n01-20 22:43:19.404: D/AndroidRuntime(17990): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<\r\n01-20 22:43:19.404: D/AndroidRuntime(17990): CheckJNI is OFF\r\n01-20 22:43:19.434: D/dalvikvm(17990): Trying to load lib libjavacore.so 0x0\r\n01-20 22:43:19.444: D/dalvikvm(17990): Added shared lib libjavacore.so 0x0\r\n01-20 22:43:19.454: D/dalvikvm(17990): Trying to load lib libnativehelper.so 0x0\r\n01-20 22:43:19.454: D/dalvikvm(17990): Added shared lib libnativehelper.so 0x0\r\n01-20 22:43:19.454: D/dalvikvm(17990): No JNI_OnLoad found in libnativehelper.so 0x0, skipping init\r\n01-20 22:43:19.504: D/dalvikvm(17990): Note: class Landroid/app/ActivityManagerNative; has 179 unimplemented (abstract) methods\r\n01-20 22:43:19.725: D/AndroidRuntime(17990): Calling main entry com.android.commands.am.Am\r\n01-20 22:43:19.725: I/ActivityManager(610): Force stopping com.billdawson.timob3286 appid=10219 user=0: from pid 17990\r\n01-20 22:43:19.725: I/ActivityManager(610): Killing 17954:com.billdawson.timob3286/u0a219 (adj 0): stop com.billdawson.timob3286\r\n01-20 22:43:19.725: W/ActivityManager(610): Force removing ActivityRecord{41f16980 u0 com.billdawson.timob3286/org.appcelerator.titanium.TiActivity t1307}: app died, no saved state\r\n01-20 22:43:19.735: I/ActivityManager(610): Force finishing activity ActivityRecord{41f0f1e0 u0 com.billdawson.timob3286/.Timob3286Activity t1307}\r\n01-20 22:43:19.745: I/ActivityManager(610): Force stopping service ServiceRecord{437b1060 u0 com.billdawson.timob3286/.TestserviceService}\r\n01-20 22:43:19.765: D/AndroidRuntime(17990): Shutting down VM\r\n01-20 22:43:19.765: W/InputDispatcher(610): channel '426cf850 com.billdawson.timob3286/org.appcelerator.titanium.TiActivity (server)' ~ Consumer closed input channel or an error occurred. events=0x9\r\n01-20 22:43:19.765: I/WindowState(610): WIN DEATH: Window{426c8370 u0 com.billdawson.timob3286/com.billdawson.timob3286.Timob3286Activity}\r\n01-20 22:43:19.775: E/InputDispatcher(610): channel '426cf850 com.billdawson.timob3286/org.appcelerator.titanium.TiActivity (server)' ~ Channel is unrecoverably broken and will be disposed!\r\n01-20 22:43:19.775: D/jdwp(17990): Got wake-up signal, bailing out of select\r\n01-20 22:43:19.775: D/dalvikvm(17990): Debugger has detached; object registry had 1 entries\r\n01-20 22:43:19.785: W/InputDispatcher(610): Attempted to unregister already unregistered input channel '426cf850 com.billdawson.timob3286/org.appcelerator.titanium.TiActivity (server)'\r\n01-20 22:43:19.785: I/WindowState(610): WIN DEATH: Window{426cf850 u0 com.billdawson.timob3286/org.appcelerator.titanium.TiActivity}\r\n01-20 22:43:19.885: W/Binder(852): Caught a RuntimeException from the binder stub implementation.\r\n01-20 22:43:19.885: W/Binder(852): java.lang.NullPointerException\r\n01-20 22:43:19.885: W/Binder(852): \tat android.inputmethodservice.IInputMethodWrapper.setSessionEnabled(IInputMethodWrapper.java:280)\r\n01-20 22:43:19.885: W/Binder(852): \tat com.android.internal.view.IInputMethod$Stub.onTransact(IInputMethod.java:129)\r\n01-20 22:43:19.885: W/Binder(852): \tat android.os.Binder.execTransact(Binder.java:404)\r\n01-20 22:43:19.885: W/Binder(852): \tat dalvik.system.NativeStart.run(Native Method)\r\n01-20 22:43:19.885: W/InputMethodManagerService(610): Got RemoteException sending setActive(false) notification to pid 17954 uid 10219\r\n01-20 22:43:20.005: V/RenderScript(17769): Application requested CPU execution\r\n01-20 22:43:20.015: V/RenderScript(17769): 0x7683d6a8 Launching thread(s), CPUs 4\r\n{code} \r\n\r\nthe service won't restart. can you verify that it is still working there?\r\n\r\nAndroid 4.4.2, Nexus 4, Ti 3.2.0", "updateAuthor": { "name": "michael", "key": "michael", "displayName": "Michael Gangolf", "active": true, "timeZone": "Europe/Berlin" }, "created": "2014-01-20T21:53:54.000+0000", "updated": "2014-01-20T21:53:54.000+0000" }, { "id": "415752", "author": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Closing ticket as fixed.", "updateAuthor": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2017-03-24T20:51:40.000+0000", "updated": "2017-03-24T20:51:40.000+0000" } ], "maxResults": 12, "total": 12, "startAt": 0 } } }