On Thu, Feb 18, 2010 at 2:27 PM, cellurl <[email protected]> wrote:

> This works:
>
> public class Translate extends Activity implements OnClickListener {
>       LocationManager lm =
> (LocationManager)getSystemService(Context.LOCATION_SERVICE);
> }
>

Because your class derives from Activity, which derives from Context, where
the getSystemService is define, so it's inherited.


>  This doesn't:   (ERR sez: the method getSystemService(String) is
> undefined for the type  LunarView.LunarThread)
>
> public class LunarView extends SurfaceView implements
> SurfaceHolder.Callback {
>    class LunarThread extends Thread {
>
>            LocationManager lm =
> (LocationManager)getSystemService(Context.LOCATION_SERVICE);
>
>    }
> }
>

Because you're trying to use the function from within a thread which does
not define the function, nor does it's outer class (SurfaceView). So why
exactly would you expect this to work?

Try getContext().getSystemService().

-------------------------------------------------------------------------------------------------
TreKing - Chicago transit tracking app for Android-powered devices
http://sites.google.com/site/rezmobileapps/treking

-- 
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en

Reply via email to