Androidデバイス(Samsung Galaxy Note N7000)でLastKnownLocationsを取得できません。これは、常にnullであり、タワーはネットワークとして検出されるため、問題ありません。誰かが私の場所を取得する方法を知っていますか?
d = getResources().getDrawable(R.drawable.songs_gray);
//Placing pinpoint at location
lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
Criteria crit = new Criteria();
towers = lm.getBestProvider(crit, false);
Toast.makeText(LocationActivity.this, "Towers: " + towers, Toast.LENGTH_SHORT).show();
Location location = lm.getLastKnownLocation(towers);
Toast.makeText(LocationActivity.this, "Location: " + location, Toast.LENGTH_SHORT).show();
if(location !=null){
lat = (int) (location.getLatitude()*1E6);
longi = (int) (location.getLongitude()*1E6);
GeoPoint ourLocation = new GeoPoint(lat, longi);
OverlayItem overlayItem = new OverlayItem(ourLocation, "What's up", "2nd String");
CustomPinpoint custom = new CustomPinpoint(d, LocationActivity.this);
custom.insertPinPoint(overlayItem);
overlayList.add(custom);
}else{
Toast.makeText(LocationActivity.this, "Couldn't get provider", Toast.LENGTH_SHORT).show();
}
マニフェスト
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />