I am inside of AnalogWatchFaceService class, which is a sample Android Wear Face provided in Android Studio. I imported an API for doing something interesting and I need to pass getActivity() as a parameter for an object. http://www.hamweather.com/support/documentation/mobile/android/loading/ shows what I am trying to do exactly. Anyway it does not recognize getActivity() when I call it. I'm not really sure about what I'm looking for and neither do I know what an activity really is. Please help and thanks!
Asked
Active
Viewed 393 times
0
-
all it is looking for is context, you dont need specifically `getActivity()` – tyczj Jan 16 '15 at 20:43
-
This is a basic question and I know a little bit about using the Receiver for example where I use Context..... How would I use Context here exactly? – What Jan 16 '15 at 20:52
-
I have no idea where "here" is – tyczj Jan 16 '15 at 20:54
-
When I place Context in the parameter, will the function work the same way? I mean what do contexts really do, and how are they retrieved? I think that question might get me somewhere. – What Jan 16 '15 at 21:03
1 Answers
2
It seems the example calls getActivity()
to use the Activity
as a Context
(which is a base class for Activity
). WatchFaceService
is a subclass of Context
, so anywhere you would pass the result of getActivity()
, you can also pass this
(or if you are inside the Engine, you will pass AnalogWatchFaceService.this
).

gruszczy
- 40,948
- 31
- 128
- 181