我制作了一个简单的小部件(AppWidgetProvider
)。要加载其内容,它需要连接到互联网(JSoup
是惊人的)。显然,我有一个很棒的NetworkOnMainThreadException
。我试图做AsyncTask
,但是Eclipse正在向我喊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).
,所以我无法运行它。
我怎么解决?
谢谢!
答案 0 :(得分:0)
也许你试图在声明区域中调用myAsync()。execute()?
public class MyActivity extends Activity {
new myAsync().execute();//wouldn't work
}