0

I'm trying to figure out how to launch a Service from a singleton class I've created.

According to the Android documentation, startService is a method of Context. So, in the method call I am making to the singleton class, I figured I would pass on the application Context as a parameter. Easy enough. However, when I try to use that context.startService, it says startService is not a method of Context. So how do I actually launch a Service from my own class?

API 7

Why I'm doing this:

Despite the examples that have been provided with the Android SDK (where database calls are made directly from the UI), Virgil, in his 2010 Google I/O presentation suggested a few models for REST-heavy applications that behave differently. The one I'm attempting to follow is as such (as I understand it):

Activity calls "Service Helper" (singleton), Service Helper launches Service, Service queries database for Cursor, Service also launches thread which calls web service to update database, Service notifies Service Helper that is has completed querying for Cursor, Service Helper notifies Activity that it has Cursor.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Andrew
  • 20,756
  • 32
  • 99
  • 177
  • startService definitely is a method of Context. I am doing a similar thing, however not in a singleton but a static helper method that gets the Activity's context passed in as Context parameter. Maybe you can provide a little code excerpt to tell what may be wrong in your case. – Thorstenvv Aug 29 '10 at 15:44
  • http://i35.tinypic.com/v8d2eo.png - I have a feeling you're going to point out what is wrong and I'm going to feel very stupid, but here it is. I've passed in a Context as a parameter and, using that Context, I've called startService with an Intent as a parameter. – Andrew Aug 30 '10 at 16:13

1 Answers1

1

forehead smack

I see my problem:

import sun.org.mozilla.javascript.internal.Context;
Andrew
  • 20,756
  • 32
  • 99
  • 177