Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-3292] JS service does not start when called from Android background service

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionInvalid
Resolution Date2017-06-06T18:29:11.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsAndroid
Labelsandroid, defect, reported-1.6.0
ReporterDaniel Cameron
AssigneeIngo Muschenetz
Created2011-04-15T03:41:31.000+0000
Updated2017-06-06T18:29:11.000+0000

Description

Titanium Mobile Version: 1.6.0

Reproduction steps:
* Create module that includes a service that runs when the application has been closed (eg titanium-c2dm) * Add the following the the service module:

TiJSIntervalService service = new TiJSIntervalService("c2dmHandler.js");
Intent serviceIntent = new Intent(Intent.ACTION_SEND, Uri.parse("app://c2dmHandler.js"));
serviceIntent.putExtra("interval", 2000); // work-around for 
service.onStart(serviceIntent, 1);

The following stack track is dumped:

[TRACE] E/TiUncaughtHandler( 384): (IntentService[C2DMBaseReceiver]) [10,1896] Sending event: exception on thread: IntentService[C2DMBaseReceiver] msg:java.lang.NullPointerException; Titanium 1.6.0,2011/02/23 18:08,882e81
[TRACE] E/TiUncaughtHandler( 384): java.lang.NullPointerException
[TRACE] E/TiUncaughtHandler( 384): at org.appcelerator.titanium.TiBaseService.createTiContext(TiBaseService.java:126)
[TRACE] E/TiUncaughtHandler( 384): at ti.modules.titanium.android.TiJSService.createProxy(TiJSService.java:92)
[TRACE] E/TiUncaughtHandler( 384): at ti.modules.titanium.android.TiJSService.onStart(TiJSService.java:48)
[TRACE] E/TiUncaughtHandler( 384): at com.example.mobile.C2DMReceiver.jsHandleMessage(C2DMReceiver.java:92)
[TRACE] E/TiUncaughtHandler( 384): at com.example.mobile.C2DMReceiver.onMessage(C2DMReceiver.java:67)
[TRACE] E/TiUncaughtHandler( 384): at com.google.android.c2dm.C2DMBaseReceiver.onHandleIntent(C2DMBaseReceiver.java:101)
[TRACE] E/TiUncaughtHandler( 384): at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:59)
[TRACE] E/TiUncaughtHandler( 384): at android.os.Handler.dispatchMessage(Handler.java:99)
[TRACE] E/TiUncaughtHandler( 384): at android.os.Looper.loop(Looper.java:123)
[TRACE] E/TiUncaughtHandler( 384): at android.os.HandlerThread.run(HandlerThread.java:60)
[TRACE] E/AndroidRuntime( 384): FATAL EXCEPTION: IntentService[C2DMBaseReceiver]
[TRACE] E/AndroidRuntime( 384): java.lang.NullPointerException
[TRACE] E/AndroidRuntime( 384): at org.appcelerator.titanium.TiBaseService.createTiContext(TiBaseService.java:126)
[TRACE] E/AndroidRuntime( 384): at ti.modules.titanium.android.TiJSService.createProxy(TiJSService.java:92)
[TRACE] E/AndroidRuntime( 384): at ti.modules.titanium.android.TiJSService.onStart(TiJSService.java:48)
[TRACE] E/AndroidRuntime( 384): at com.example.mobile.C2DMReceiver.jsHandleMessage(C2DMReceiver.java:92)
[TRACE] E/AndroidRuntime( 384): at com.example.mobile.C2DMReceiver.onMessage(C2DMReceiver.java:67)
[TRACE] E/AndroidRuntime( 384): at com.google.android.c2dm.C2DMBaseReceiver.onHandleIntent(C2DMBaseReceiver.java:101)
[TRACE] E/AndroidRuntime( 384): at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:59)
[TRACE] E/AndroidRuntime( 384): at android.os.Handler.dispatchMessage(Handler.java:99)
[TRACE] E/AndroidRuntime( 384): at android.os.Looper.loop(Looper.java:123)
[TRACE] E/AndroidRuntime( 384): at android.os.HandlerThread.run(HandlerThread.java:60)

Attachments

FileDateSize
servicenotification.zip2011-04-15T03:41:34.000+000010394531

Comments

  1. Daniel Cameron 2011-04-15

    Workaround: fire the intent directly instead of creating a TiService

       String serviceClass = "com.hyro.mobile.C2dmBackgroundService";
       Intent serviceIntent = new Intent(Intent.ACTION_SEND, Uri.parse("app://c2dmBackground.js"));
       serviceIntent.putExtra("interval", 2000); // .currentService undefined for non-interval services
       serviceIntent.setClassName(context, serviceClass);
       context.startService(serviceIntent);
       
  2. Daniel Cameron 2011-04-15

    Assigning to hopefully the correct person.

  3. Don Thorp 2011-04-15

    Daniel it would be helpful if you could attach a complete example to speed up the reproduction and possible fix.

  4. Daniel Cameron 2011-04-15

    Full source for reproduction against 1.6.1 attached.

    Reproduction steps:

    Start "Ticket3292" app
    Start "Ticket3292 invoker" app
    Select the "Notification to native service invoking js" notification

JSON Source