所以我在我的应用程序中为地图编写了一些代码,它在我的手机上运行得很好,遗憾的是它在我的模拟器上不起作用,这对我来说不够舒服这里是代码:
String searchString = mSearchText.getText().toString();
Geocoder geocoder = new Geocoder(this);
List<Address> list = new ArrayList<>();
try{
int i=0;
while(list.size()==0 && i<10) {
boolean a = geocoder.isPresent();
list = geocoder.getFromLocationName(searchString,1);
i++;
}
}catch(IOException e){
Log.d(TAG, "geoLocate: IOException " + e.getMessage());
}
所以当我调试它时,我看到变量“a”在我的模拟器上总是假的。
我将 android 模拟器用于 Visual Studio,因为我有一个 AMD 处理器(Ryzen 7 1800x),我在上面安装了 google play 商店和 google play 服务(地图工作得很好,只是地理编码器不行),现在有什么方法可以解决它?
正如我在https://developer.android.com/reference/android/location/Geocoder.html网站上所读到的, “如果平台中没有后端服务,Geocoder 查询方法将返回一个空列表。” 我能以某种方式获得服务吗?在我的模拟器或类似的东西上下载它?