我正在使用以下内容来模拟我的安卓设备位置。
但是它不起作用。我想在真实设备上看到泡泡在那个位置闪烁,但我什么都没有得到。请纠正我的代码,并帮助我解决问题。我已经使用了权限。
我想要构建一个类似于位置模拟器的应用程序。实际上,当我们打开谷歌地图时,它会显示我们当前位置,并在我们的位置处以蓝色闪烁显示。同样,如果我更改坐标即纬度和经度,它应该显示我在那个位置,并显示蓝色闪烁。
这是屏幕快照:
![alt text][1]
我的XML文件很好。
public class GPSwork extends Activity implements LocationListener{
LocationManager locationManager;
String mocLocationProvider;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
mocLocationProvider = LocationManager.GPS_PROVIDER;
setLocation(28.574853,78.063201);
}
public void setLocation(double latitude, double longitude) {
locationManager.addTestProvider(mocLocationProvider, false, true, false, false, false, false, false, 0, 5);
locationManager.setTestProviderEnabled(mocLocationProvider, true);
locationManager.requestLocationUpdates(mocLocationProvider, 0, 0, this);
Location loc = new Location(mocLocationProvider);
loc.setTime(System.currentTimeMillis());
loc.setLatitude(latitude);
loc.setLongitude(longitude);
locationManager.setTestProviderLocation(mocLocationProvider, loc);
}
public void onLocationChanged(Location location) {
// TODO Auto-generated method stub
}
public void onProviderDisabled(String provider) {
// TODO Auto-generated method stub
}
public void onProviderEnabled(String provider) {
// TODO Auto-generated method stub
}
public void onStatusChanged(String provider, int status, Bundle extras) {
// TODO Auto-generated method stub
}
}
但是它不起作用。我想在真实设备上看到泡泡在那个位置闪烁,但我什么都没有得到。请纠正我的代码,并帮助我解决问题。我已经使用了权限。
我想要构建一个类似于位置模拟器的应用程序。实际上,当我们打开谷歌地图时,它会显示我们当前位置,并在我们的位置处以蓝色闪烁显示。同样,如果我更改坐标即纬度和经度,它应该显示我在那个位置,并显示蓝色闪烁。
这是屏幕快照:
![alt text][1]
我的XML文件很好。
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.maps.MapView
android:id="@+id/mapView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:apiKey="0Sy8vgJlQkFxcisUAkrxu3xN33dqFgBetCg4jxg"
/>