The location and context APIs harness the sensors and signals of mobile devices to provide awareness of user actions and their environment, enabling delightful and engaging experiences that simplify user interactions, provide assistance, and help users to better understand themselves.
This repo contains the following samples:
-
Activity Recognition (Java) - Demonstrates the ActivityRecognitionApi to determine the user's current activity.
-
AwarenessApisSampleKotlin (Kotlin) - Demonstrates use of the Awareness APIs to intelligently react to the current situation of the user.
-
BasicLocation (Java) - Demonstrates use of the Google Play services Location API to retrieve the last known location for a device.
-
BasicLocation (Kotlin) - Same as above but in Kotlin.
-
CurrentLocationKotlin (Kotlin) - This app allows a user to request a current location without subscribing to location updates.
-
Geofencing (Java) - Create geofences and process enter and exit transitions.
-
LocationAddress (Java) - Use the Geocode API to display a device's location as an address.
-
LocationAddressKotlin (Kotlin) - Same as above but in Kotlin.
-
LocationUpdates (Java) - Get updates about a device's location.
-
LocationUpdatesBackgroundKotlin (Kotlin) - Demonstrates the correct way to retrieve location updates in the background.
-
LocationUpdatesForegroundService (Java) - Get updates about a device's location using a bound and started foreground service.
-
LocationUpdatesPendingIntent (Java) - Get updates about a device's location using a
PendingIntent
. Sample shows implementation using anIntentService
as well as aBroadcastReceiver
. -
SleepSampleKotlin (Kotlin) - Demonstrates use of the Sleep API to recognize a user's sleep activity.
- Android API Level >v9
- Android Build Tools >v21
- Google Support Repository
These samples use the Gradle build system. To build a sample, use the "gradlew build" command or use "Import Project" in Android Studio.
- Stack Overflow: http://stackoverflow.com/questions/tagged/google-play-services
If you've found an error in these samples, please file an issue: https://github.com/android/location-samples/issues
Patches are encouraged, and may be submitted according to the instructions in CONTRIBUTING.md.