{ "id": "125133", "key": "AC-2597", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "12217", "key": "AC", "name": "Appcelerator - INBOX", "projectCategory": { "id": "10000", "description": "", "name": "Customer Service" } }, "resolution": { "id": "7", "description": "", "name": "Invalid" }, "resolutiondate": "2014-02-18T05:23:00.000+0000", "created": "2014-01-21T18:00:09.000+0000", "labels": [], "versions": [], "issuelinks": [], "assignee": { "name": "ragrawal", "key": "ragrawal", "displayName": "Ritu Agrawal", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2016-03-08T07:41: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": [], "description": "I'm using a native Android module that creates a service like this:\r\n\r\n{code}\r\npackage com.test.jsservice;\r\nimport ti.modules.titanium.android.TiJSService;\r\npublic final class TestJsService extends TiJSService {\r\n\tpublic TestJsService() {\r\n\t\tsuper(\"testservice.js\");\r\n\t}\r\n}\r\n{code}\r\n\r\nIn testservice.js run these lines:\r\n\r\n{code}\r\nvar player = Ti.Media.createSound({url: \"sound.wav\"});\r\nplayer.play();\r\n{code}\r\n\r\nThis will crash with null exception at SoundProxy.java in initActivity(Activity activity), as activity is null.\r\n{noformat}\r\n01-22 10:34:42.301: E/KrollProxy(3098): (KrollRuntimeThread) [215,97313] Error creating proxy\r\n01-22 10:34:42.301: E/KrollProxy(3098): java.lang.NullPointerException\r\n01-22 10:34:42.301: E/KrollProxy(3098): \tat ti.modules.titanium.media.SoundProxy.initActivity(SoundProxy.java:64)\r\n01-22 10:34:42.301: E/KrollProxy(3098): \tat org.appcelerator.kroll.KrollProxy.setupProxy(KrollProxy.java:129)\r\n01-22 10:34:42.301: E/KrollProxy(3098): \tat org.appcelerator.kroll.KrollProxy.createProxy(KrollProxy.java:140)\r\n01-22 10:34:42.301: E/KrollProxy(3098): \tat org.appcelerator.kroll.runtime.v8.V8Runtime.nativeRunModule(Native Method)\r\n01-22 10:34:42.301: E/KrollProxy(3098): \tat org.appcelerator.kroll.runtime.v8.V8Runtime.doRunModule(V8Runtime.java:159)\r\n01-22 10:34:42.301: E/KrollProxy(3098): \tat org.appcelerator.kroll.KrollRuntime.handleMessage(KrollRuntime.java:289)\r\n01-22 10:34:42.301: E/KrollProxy(3098): \tat org.appcelerator.kroll.runtime.v8.V8Runtime.handleMessage(V8Runtime.java:185)\r\n01-22 10:34:42.301: E/KrollProxy(3098): \tat android.os.Handler.dispatchMessage(Handler.java:95)\r\n01-22 10:34:42.301: E/KrollProxy(3098): \tat android.os.Looper.loop(Looper.java:137)\r\n01-22 10:34:42.301: E/KrollProxy(3098): \tat org.appcelerator.kroll.KrollRuntime$KrollRuntimeThread.run(KrollRuntime.java:112)\r\n01-22 10:34:42.301: A/libc(3098): Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1), thread 3133 (KrollRuntimeThr)\r\n{noformat}\r\n\r\nTo fix this bug, you just need to test for activity!=null:\r\n\r\n{code}\r\n\t@Override\r\n\tprotected void initActivity(Activity activity) {\r\n\t\tsuper.initActivity(activity);\r\n\t\tif (activity != null) {\r\n\t\t\t((TiBaseActivity) activity).addOnLifecycleEventListener(this);\r\n\t\t\t((TiBaseActivity) activity).addOnWindowFocusChangedEventListener(this);\r\n\t\t}\r\n\t}\r\n{code}", "attachment": [], "flagged": false, "summary": "Playing a sound from an Android service, crashes the process, as the activity is null", "creator": { "name": "buddyguards", "key": "buddyguards", "displayName": "grebulon", "active": true, "timeZone": "Asia/Jerusalem" }, "subtasks": [], "reporter": { "name": "buddyguards", "key": "buddyguards", "displayName": "grebulon", "active": true, "timeZone": "Asia/Jerusalem" }, "environment": "Titanium 3.2.0\r\nAndroid 4.3", "comment": { "comments": [ { "id": "289119", "author": { "name": "ragrawal", "key": "ragrawal", "displayName": "Ritu Agrawal", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Thanks for proposing the solution but it would be helpful if we have a log trace. Can you please attach the log trace for this issue?", "updateAuthor": { "name": "ragrawal", "key": "ragrawal", "displayName": "Ritu Agrawal", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2014-01-21T21:20:22.000+0000", "updated": "2014-01-21T21:20:22.000+0000" }, { "id": "289313", "author": { "name": "ayeung", "key": "ayeung", "displayName": "Allen Yeung", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Just curious if you tried this with an Android service via the titnaium API. It's not clear to me why you need to create a native module for this. It would be helpful to narrow this down to see if it happens without the native module component. You can read more about the Titanium Android Service APIs here: http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.Android.Service", "updateAuthor": { "name": "ayeung", "key": "ayeung", "displayName": "Allen Yeung", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2014-01-22T23:40:47.000+0000", "updated": "2014-01-22T23:40:47.000+0000" }, { "id": "289378", "author": { "name": "buddyguards", "key": "buddyguards", "displayName": "grebulon", "active": true, "timeZone": "Asia/Jerusalem" }, "body": "Haven't tested it with Ti,Android.Service. I need a service for various reasons, one of which to receive GCM push notifications. That's why I made a module, it was just simpler.\nThe bottom line is that there may not be an activity when playing a sound.\nI suspect there may be more things that won't work when calling from a service, just haven't found them yet. I will report if I encounter anything.", "updateAuthor": { "name": "buddyguards", "key": "buddyguards", "displayName": "grebulon", "active": true, "timeZone": "Asia/Jerusalem" }, "created": "2014-01-23T07:44:25.000+0000", "updated": "2014-01-23T07:44:25.000+0000" }, { "id": "289560", "author": { "name": "ragrawal", "key": "ragrawal", "displayName": "Ritu Agrawal", "active": true, "timeZone": "America/Los_Angeles" }, "body": "I am curious if you have tried ACS GCM push notification service. It is integrated very well with Titanium and may eliminate the need for you to write your own GCM module.\n\nhttp://docs.appcelerator.com/cloud/latest/#!/api/PushNotifications\n", "updateAuthor": { "name": "ragrawal", "key": "ragrawal", "displayName": "Ritu Agrawal", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2014-01-24T06:42:17.000+0000", "updated": "2014-01-24T06:42:17.000+0000" }, { "id": "293492", "author": { "name": "ragrawal", "key": "ragrawal", "displayName": "Ritu Agrawal", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Resolving this ticket as we have not received the requested information and we don't have a test case to reproduce this problem. ", "updateAuthor": { "name": "ragrawal", "key": "ragrawal", "displayName": "Ritu Agrawal", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2014-02-18T05:23:00.000+0000", "updated": "2014-02-18T05:23:00.000+0000" } ], "maxResults": 5, "total": 5, "startAt": 0 } } }