我從這裏如何與後臺任務在RoboAsyncTask以下工作的例子:https://code.google.com/p/roboguice/wiki/RoboAsyncTask如何綁定ProgressDialog到RoboAsyncTask
然而,在我的代碼,當我嘗試@Inject ProgressDialog dialog
我得到一個運行時錯誤:
Process: com.aerstone.mobile, PID: 5118
com.google.inject.ConfigurationException: Guice configuration errors:
1) Could not find a suitable constructor in android.app.ProgressDialog. Classes
must have either one (and only one) constructor annotated with @Inject or a
zero-argument constructor that is not private.
at android.app.ProgressDialog.class(Unknown Source)
while locating android.app.ProgressDialog
for field at com.aerstone.mobile.ui.task.SaveUserProfileTask.dialog(Unknown Source)
while locating com.aerstone.mobile.ui.task.MyTask
我的代碼是像這樣:
public class MyTask extends RoboAsyncTask<String> {
@Inject protected ProgressDialog dialog;
protected String name;
public MyTask (Context context, String name) {
super(context);
this.name = name;
}
....
}
它從這樣一個活動叫做:new MyTask(getApplicationContext(), "some name").execute();