开发者

implementing Geocoder

I'm trying to implement Geocoder in a class that implements Runnable and I get er开发者_JAVA技巧ror at this line:

Geocoder myLocation = new Geocoder(this, Locale.getDefault());

I don't think Android likes this.

But what context should I pass in for this to work?

public class ClientThread_special implements Runnable {

    public void run() {
        Geocoder myLocation = new Geocoder(this, Locale.getDefault());
    } 

}

I'm trying to implement the Geocoder in a class that doesn't extend Activity and I have problems in passing the context for the Geocoder constructor.

Android doesn't like this for my class. I also tried with getApplicationContext...but still it says that "it can't be resolved..".


You must pass Context instance somehow. Without it Geocoder won't work.


If you need Context instance and don't need an activity,extend the class ClientThread_special with Service and I think you wont need Runnable then.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜