gpt4 book ai didi

android - 在 Android 中使用 GPS 进行虚假定位

转载 作者:太空宇宙 更新时间:2023-11-03 10:31:50 25 4
gpt4 key购买 nike

您好,我正在开发一个可以设置坐标(纬度和经度)的应用程序。它必须显示我在那个坐标处的位置。它类似于位置欺骗器。http://www.androidzoom.com/android_applications/tools/location-spoofer_gkmc.html但我没有做到这一点..这是我的代码..请任何人帮助我。

public class Mock extends MapActivity 
{
private LocationManager lm;
private LocationListener locationListener;

private MapView mapView;
String mocLocationProvider;
private MapController mc;


/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

//---use the LocationManager class to obtain GPS locations---
lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE);

locationListener = new MyLocationListener();

mocLocationProvider=LocationManager.GPS_PROVIDER;

lm.addTestProvider(mocLocationProvider, false, false,false, false, true, true, true, 0, 5);
lm.setTestProviderEnabled(mocLocationProvider,true);
lm.requestLocationUpdates(mocLocationProvider,0,0,locationListener);


mapView = (MapView) findViewById(R.id.mapview1);
mc = mapView.getController();

}

@Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}

private class MyLocationListener implements LocationListener
{
@Override
public void onLocationChanged(Location loc) {

loc = new Location(mocLocationProvider);

Double latitude = 1.352566007;
Double longitude = 103.78921587;

//Double altitude = Double.valueOf(parts[2]);

loc.setLatitude(latitude);
loc.setLongitude(longitude);
loc.setTime(System.currentTimeMillis());
lm.setTestProviderLocation(mocLocationProvider, loc);


mc.setZoom(16);
mapView.invalidate();

}

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

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

@Override
public void onStatusChanged(String provider, int status,
Bundle extras) {
// TODO Auto-generated method stub
}
}
}

最佳答案

关于android - 在 Android 中使用 GPS 进行虚假定位,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3794950/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com