I'm adding a function in a my app that will show specific places near the user.
( Here is the example that I embedded )
Follow screen print in activity:
EDIT:
E/GoogleMapsAndroidAPI(21658):Authorizationfailure.PleaseseetheGoogleConsoleforhowtocorrectlysetupthemap.E/GoogleMapsAndroidAPI(21658):IntheGoogleDeveloperConsoleE/GoogleMapsAndroidAPI(21658):Ensurethatthe"Google Maps Android API v2" is enabled.
E/Google Maps Android API(21658): Ensure that the following Android Key exists:
E/Google Maps Android API(21658): API Key: AIzaSyA********************************
E/Google Maps Android API(21658): Android Application (<cert_fingerprint>;<package_name>): 42:89:CD:56:4E:08:9A:67:**:**:**:**:**:**:**:**:**:**:**:**;"NOME DO MEU PACOTE"
The key is created, but the above error occurs
A NullPointer also occurs:
java.lang.NullPointerException: Attempt to invoke virtual method 'double android.location.Location.getLatitude()' on a null object reference
I did not even change anything in the class.
The section where the error occurs:
Line 72:
StringBuilder sbValue = new StringBuilder(sbMethod());
Line 144:
public StringBuilder sbMethod() throws SecurityException {
LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
Criteria criteria = new Criteria();
String provider = locationManager.getBestProvider(criteria, true);
Location myLocation = locationManager.getLastKnownLocation(provider);
mLatitude = myLocation.getLatitude();
mLongitude = myLocation.getLongitude();