【发布时间】:2013-09-20 09:45:55
【问题描述】:
今天我的 G. Analytics 帐户报告我在这行代码中出现错误
private class GetSubscriptionListTask extends AsyncTask<Void, Void, Void> {
boolean onlyUnread=true;
public GetSubscriptionListTask(boolean onlyUnread) {
super();
this.onlyUnread=onlyUnread;
}
ProgressDialog progress;
@Override
protected void onPreExecute() {
//Show progress Dialog here
super.onPreExecute();
// create ProgressDialog here ...
progress = new ProgressDialog(getActivity()); // <-- That's the line
progress.setMessage("Downloading Subscriptions");
// set other progressbar attributes
progress.setCancelable (false);
progress.setIndeterminate (true);
progress.show();
}
}
这是行
progress = new ProgressDialog(getActivity()); // <-- That's the line
这是错误报告
NullPointerException (@SubscriptionsListFragment$GetSubscriptionListTask:onPreExecute:415) {main}
这是什么意思? nullexception 是关于 ProgressDialog 还是 getActivity()?
*更新** 此错误仅在 100 多个会话中发生一次。
【问题讨论】:
-
你最好在
**oncreate**方法中初始化你的进度条,你也可以把getActivity()改成YouCLassName.this -
此错误仅在 100 多个会话中发生一次。
标签: java android exception android-asynctask