Search code examples
androidandroid-activityandroid-studiowear-oswatch-face-api

Where is getActivity() on Android Wear Face?


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!


Solution

  • 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).