私はアンドロイドアプリケーションに取り組んでいます。私は問題で立ち往生しています。
getLastKnownLocation(provider)
Android バージョン 4.1.1 では返さnull
れますが、他のバージョンでは問題ありません。プロバイダーが有効になっており、残りは問題ありません。どこに問題があるのかわからない。これがコードです。
LocationManager locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
Criteria criteria = new Criteria();
String provider = locationManager.getBestProvider(criteria, true);
location = locationManager.getLastKnownLocation(provider);
double latitude = location.getLatitude();
double longitude = location.getLongitude();
LatLng latLng = new LatLng(latitude, longitude);
mMap.clear();
System.out.println("Current Location = "+latLng);