2012-07-12 76 views
0

我想在android上創建地理位置代碼。即使我在模擬器中得到結果,我仍然在logcat窗口中收到以下錯誤。嘗試獲取地理位置時找不到提供程序

07-12 10:45:24.300: E/ActivityThread(237): Failed to find provider info for com.google.settings 
07-12 10:45:24.310: E/ActivityThread(237): Failed to find provider info for com.google.settings 
07-12 10:45:24.371: E/ActivityThread(237): Failed to find provider info for com.google.settings 

回答

0

您可能沒有給予應用程序訪問這些提供程序的權限。

我不知道你的實現,因爲你還沒有給出任何代碼,但我認爲你可能需要互聯網,粗略的位置和良好的位置。我已經添加了一些額外的人只是櫃面:

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> 
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> 
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" /> 
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" /> 
<uses-permission android:name="android.permission.CONTROL_LOCATION_UPDATES" /> 
<uses-permission android:name="android.permission.INTERNET" /> 

只是<application ..>標記之前在清單文件把這些。

如果你使用的地圖,確保這是您的<application ..>標籤中:

<uses-library android:name="com.google.android.maps" /> 
+0

你好 這種工作,但現在我有以下錯誤s: – sigway 2012-07-13 01:40:45

0

這樣的工作,但現在我有以下錯誤:

07-13 01:37 :07.171:E/QemuSensors(333):data_ poll:len = -1,errno = 9:錯誤的文件號 07-13 01:37:07.171:E/QemuSensors(333):data _poll:len = - 1,errno = 9:錯誤的文件號 07-13 01:37:07.211:E/QemuSensors(333):data_ poll:len = -1,errno = 9:錯誤的文件號 07-13 01:37:07.211:E/QemuSensors(333):data _poll:len = -1,errno = 9:錯誤的文件號 07-13 01:37:07.211:E/QemuSensors(333) data_ poll:len = -1,errno = 9:錯誤的文件號 07-13 01:37:07.211:E/QemuSensors(333):data _poll:len = -1,errno = 9:錯誤的文件號 07-13 01:37:07.511:E/QemuSensors(333):data_ poll:len = -1,errno = 9:錯誤的文件號 07-13 01:37:07.646:E/QemuSensors(333) _poll:len = -1,errno = 9:錯誤的文件號 07-13 01:37:07.646:E/QemuSensors(333):data_ poll:len = -1,errno = 9:錯誤的文件號 07 -13 01:37:07.661:E/QemuSensors(333):data _poll:len = -1,err no = 9:錯誤的文件號 07-13 01:37:07.661:E/QemuSensors(333):data_ poll:len = -1,errno = 9:錯誤的文件號 07-13 01:37:07.670: E/QemuSensors(333):數據 _poll:LEN = -1,錯誤號= 9:錯誤的文件號

這裏是代碼

package com.android.map; 

    import android.location.Location; 
    import android.location.LocationListener; 
    import android.location.LocationManager; 
    import android.os.Bundle; 
    import android.view.KeyEvent; 
    import android.widget.Toast; 

    import com.google.android.maps.GeoPoint; 
    import com.google.android.maps.MapActivity; 
    import com.google.android.maps.MapController; 
    import com.google.android.maps.MapView; 
    import com.google.android.maps.MyLocationOverlay; 

    public class HelloGoogleMapActivity extends MapActivity implements LocationListener 
    { 

private MapView mapView = null; 
private LocationManager lm = null; 
private double lat = 0; 
private double lng = 0; 
private MapController mc = null; 
private MyLocationOverlay myLocation = null; 

@Override 
    public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.main);   
    mapView = (MapView) this.findViewById(R.id.mapView); 
    mapView.setBuiltInZoomControls(true); 

    lm = (LocationManager) this.getSystemService(LOCATION_SERVICE); 
    lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 10000, 0, this); 
    lm.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 10000, 0, this); 

    mc = mapView.getController(); 
    mc.setZoom(12); 
    myLocation = new MyLocationOverlay(getApplicationContext(),mapView); 
    myLocation.runOnFirstFix(new Runnable(){ 
    public void run(){ 
     mc.animateTo(myLocation.getMyLocation()); 
     mc.setZoom(17); 
    } 
    }); 

    mapView.getOverlays().add(myLocation); 
    myLocation.enableMyLocation(); 
    myLocation.enableCompass(); 
} 

@Override 
protected boolean isRouteDisplayed() 
{ 
    return false; 
} 

@Override 
public boolean onKeyDown(int keyCode, KeyEvent event) 
{ 
    if (keyCode == KeyEvent.KEYCODE_S) 
    { 
     mapView.setSatellite(!mapView.isSatellite()); 
     return true; 
    } 
    return super.onKeyDown(keyCode, event); 
} 

@Override 
public void onLocationChanged(Location location) { 
    // TODO Auto-generated method stub 
    lat = location.getLatitude(); 
    lng = location.getLongitude(); 
    Toast.makeText(getBaseContext(), 
    "Location change to : Latitude = " + lat + " Longitude = " + lng, 
    Toast.LENGTH_SHORT).show(); 
    GeoPoint p = new GeoPoint((int) (lat * 1E6), (int) (lng * 1E6)); 
    mc.animateTo(p); 
    mc.setCenter(p); 
} 

@Override 
public void onProviderDisabled(String arg0) { 
    // TODO Auto-generated method stub 

} 

@Override 
public void onProviderEnabled(String arg0) { 
    // TODO Auto-generated method stub 

} 

@Override 
public void onStatusChanged(String arg0, int arg1, Bundle arg2) { 
    // TODO Auto-generated method stub 

} 

}

感謝ü的幫助

相關問題