GetBaseContext () method - undefined for type MyMapOverlay in android? What for?

I am creating a Geocoder object, for example.

Geocoder geoCoder = new Geocoder(getBaseContext(), Locale.getDefault()); 

here i got this error in eclipse. i.e.

 The method getBaseContext() is undefined for the type MyMapOverlay 

getBaseContext () is the default method in the android.content.ContextWrapper class.

what is the problem here .. any idea ???

+4
source share
1 answer

Question: in what class do you create the Geocoder object? GetBaseContext () does not work in a class that extends from Overlay, because Overlay is not a child of ContextWrapper.
It exists in your MapActivity if you use it. The easiest way to solve the problem is to provide an Overlay context as a parameter / setter method.

+2
source

Source: https://habr.com/ru/post/1302847/


All Articles