This first recipe will show you how to get the last known location. If you've worked with the Google Location APIs in the past, then you may notice things have changed. This recipe shows you the latest API for getting both the last location and updates as the location changes.
How to get the device location
Getting ready
Create a new project in Android Studio and call it GetLocation. Use the default Phone & Tablet options, and select Empty Activity when prompted for Activity Type.
How to do it...
First, we'll add the necessary permissions to the Android Manifest...