首页 新闻 会员 周边 捐助

安卓模拟GPS地址,在地图或是其它程序上无法得到模拟的地址

0
悬赏园豆:50 [待解决问题]

使用地址模拟了地图上的一个点
但是却在地图上看不到定位在这个点,并且使用 微信查找附近的人,却提示无法获取位置住处,代码如下 

Criteria criteria = new Criteria();
//  criteria.setAccuracy(Criteria.ACCURACY_FINE);
  String serviceName = Context.LOCATION_SERVICE;
  LocationManager locationManager = (LocationManager) getSystemService(serviceName);
//  String provider = locationManager.getBestProvider(criteria, true);
  

  if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
   Log.d("provider", "gps enable");
  } else {
   // locationManager.addTestProvider(LocationManager.GPS_PROVIDER,
   // false, false,
   // false, false, true, false, false, 0, 5);
   locationManager.addTestProvider(LocationManager.GPS_PROVIDER,
     "requiresNetwork" == "", "requiresSatellite" == "",
     "requiresCell" == "", "hasMonetaryCost" == "",
     "supportsAltitude" == "", "supportsSpeed" == "",
     "supportsBearing" == "",
     android.location.Criteria.POWER_LOW,
     android.location.Criteria.ACCURACY_FINE);
   locationManager.setTestProviderEnabled(LocationManager.GPS_PROVIDER, true);
   Log.d("provider", "add gps test provider ");
  }
  
  //
  listener = new LocationListener() {
   @Override
   public void onLocationChanged(Location location) {
    // TODO Auto-generated method stub
    Log.i("onLocationChanged", "come in");
    if (location != null) {
     Log.w("Location",
       "Current altitude = " + location.getAltitude()); //altitude 地平纬度
     Log.w("Location",
       "Current latitude = " + location.getLatitude()); //latitude
    }
    // locationManager.removeUpdates(this);
    // locationManager.setTestProviderEnabled(provider, false);
   }

   @Override
   public void onProviderDisabled(String provider) {
    // TODO Auto-generated method stub
    Log.i("onProviderDisabled", "come in");

   }

   @Override
   public void onProviderEnabled(String provider) {
    // TODO Auto-generated method stub
    Log.i("onProviderEnabled", "come in");
   }

   @Override
   public void onStatusChanged(String provider, int status,
     Bundle extras) {
    // TODO Auto-generated method stub
    Log.i("onStatusChanged", "come in");

   }

  };
  
  locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, (float) 1000.0,listener);
  Log.d("provider", "add location litersoner ");
  Location location = new Location(LocationManager.GPS_PROVIDER);
  
  location.setLatitude(22.575212D); //纬度
  location.setLongitude(113.872068D); //经度
  location.setAccuracy(16F);
  location.setAltitude(0D);
  location.setTime(System.currentTimeMillis());
  location.setBearing(0F);
  
  try {
   Method makeComplete = Location.class.getMethod("makeComplete");
   if (makeComplete != null) {
    makeComplete.invoke(location);
    Log.d("provider", "invoke ");
   }
  } catch (Exception e) {
   // Method only available in Jelly Bean
  }
  locationManager.setTestProviderLocation(locationManager.GPS_PROVIDER,location);
LovlyPuppy的主页 LovlyPuppy | 初学一级 | 园豆:152
提问于:2013-04-13 12:07
< >
分享
所有回答(2)
0

你好,我也碰到这个问题了,微信不能用模拟的地址,而且我把模拟定位开了,网络定位关了,微信还是不用我模拟的定位

牛孝祖 | 园豆:202 (菜鸟二级) | 2013-09-18 13:34

你好 这个问题你的进展如何?为啥google mock pro能做呵

支持(0) 反对(0) wzp_124 | 园豆:202 (菜鸟二级) | 2014-01-11 16:00

@wzp_124: →_→ 连我回复的你都问,,,我想想啊,,,我都忘了,我好像没再去实现,因为没意义了。这得看微信的定位是怎么获取的,烦了就不弄了,

支持(0) 反对(0) 牛孝祖 | 园豆:202 (菜鸟二级) | 2014-01-11 16:45
0

我也遇到这个问题了 你们解决了么

wzp_124 | 园豆:202 (菜鸟二级) | 2014-01-11 16:00
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册