本文介绍了使用android系统的GPS定位假的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
喜正在开发一个应用程序,将设置坐标(经度和纬度)。它具有显示我的位置我在这coordinates..It类似于位置欺骗者..的
但我没能做到这一点..这里是我的code..Please任何一个可以帮助我。
公共类模拟扩展MapActivity
{
私人的LocationManager流明;
私人LocationListener的LocationListener的; 私人MapView类MapView类;
串mocLocationProvider;
私人MapController MC;
/ **当第一次创建活动调用。 * /
@覆盖
公共无效的onCreate(捆绑savedInstanceState){
super.onCreate(savedInstanceState);
的setContentView(R.layout.main); // ---使用的LocationManager类来获取GPS位置---
LM =(的LocationManager)getSystemService(Context.LOCATION_SERVICE); LocationListener的=新MyLocationListener(); mocLocationProvider = LocationManager.GPS_PROVIDER; lm.addTestProvider(mocLocationProvider,假的,假的,假的,假的,真实的,真实的,真实的,0,5);
lm.setTestProviderEnabled(mocLocationProvider,真);
lm.requestLocationUpdates(mocLocationProvider,0,0,LocationListener的);
图形页面=(图形页面)findViewById(R.id.mapview1);
MC = mapView.getController(); } @覆盖
保护布尔isRouteDisplayed(){
// TODO自动生成方法存根
返回false;
} 私有类MyLocationListener实现LocationListener的
{
@覆盖
公共无效onLocationChanged(位置LOC){ LOC =新位置(mocLocationProvider); 双纬度= 1.352566007;
双经度= 103.78921587; //双海拔= Double.valueOf(部件[2]); loc.setLatitude(纬度);
loc.setLongitude(经度);
loc.setTime(System.currentTimeMillis的());
lm.setTestProviderLocation(mocLocationProvider,LOC);
mc.setZoom(16);
mapView.invalidate(); } @覆盖
公共无效onProviderDisabled(字符串提供商){
// TODO自动生成方法存根
} @覆盖
公共无效onProviderEnabled(字符串提供商){
// TODO自动生成方法存根
} @覆盖
公共无效onStatusChanged(字符串提供商,INT状态,
捆绑演员){
// TODO自动生成方法存根
}
}
}
解决方案
我会用这种方法的。没有试过这样:
Hi am developing an app that will set the coordinates(latitude and longitude). And it has to show my location as i am at that coordinates..It is similar to location spoofer.. http://www.androidzoom.com/android_applications/tools/location-spoofer_gkmc.htmlBut I am failing to do that.. here is my code..Please any one help me.
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
}
}
}
解决方案
I would use this method http://developer.android.com/guide/developing/tools/ddms.html#emulator-control. Haven't tried this one: http://code.google.com/p/android/issues/detail?id=915
这篇关于使用android系统的GPS定位假的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!