0

I made a simple widget (AppWidgetProvider). To load its content, it needs to connect to the internet (JSoup is amazing). Obviously, I've got a wonderful NetworkOnMainThreadException. I tried to do an AsyncTask but Eclipse is shouting No enclosing instance of type WidgetClass is accessible. Must qualify the allocation with an enclosing instance of type WidgetClass (e.g. x.new A() where x is an instance of WidgetClass). at me, so I can't run it.

How could I solve it ?

Thanks !

4

1 回答 1

0

也许您正试图在声明区域调用 myAsync().execute() ?

public class MyActivity extends Activity {
    new myAsync().execute();//wouldn't work
}
于 2013-01-17T21:31:16.590 回答