if (Geocoder.isPresent()) {
geocoder = new Geocoder(MapActivity.this.getactivity,Locale.getDefault());
这是doitbackground
的{{1}}内。它是地图活动的asynctask
。
但我不能这样做。错误是:
inner class
当我只做这个时。
它说
mapactivity not enclosing class
"The constructor Geocoder(Context, Locale) is undefined"?
Error: The constructor Geocoder (Context, Locale) is undefined
那些没有用的,因为我在内班。我不能使用构造函数初始化上下文?同时将内部类名称作为第一个参数也不起作用。
错误:
in geocoder can not be applied context
答案 0 :(得分:0)
在活动顶部附近声明一个上下文变量并获取上下文:
Context context = YourActivity.getApplicationContext();
然后将您的上下文变量用于地理编码器:
if (Geocoder.isPresent()) {
geocoder = new Geocoder(context, Locale.getDefault());