我正在尝试在三星 Galaxy Grand 上运行我的应用程序,但它没有显示我当前的位置。
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
// Creating a criteria object to retrieve provider
Criteria criteria = new Criteria();
// Getting the name of the best provider
String provider = locationManager.getBestProvider(criteria, true);
System.out.println("provider => " + provider);
// Getting Current Location
Location location = locationManager.getLastKnownLocation(provider);
System.out.println("location " + location);
但总是这一行返回 null locationManager.getLastKnownLocation(provider); 但这个应用程序在索尼和 lg等其他手机上运行良好。
我尝试了很多链接,但仍然是同样的问题。
getLastKnownLocation() 总是返回 null,所有提供者都是 DummyLocationProvider
Android LocationManager.getLastKnownLocation() 返回 null
允许
<permission
android:name="xx.xxx.xxx.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="xicom.biz.perdiem.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<application android:label="@string/app_name" >
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyccccccccbvxcbpmFLAZwalBGM" />
......