【发布时间】:2014-07-12 13:45:27
【问题描述】:
大家好,在我的应用程序中,我正在 asynctask 类中添加进度对话框,如下所示。这个 asynctask 在 oncreate 方法中调用。
class GettingData extends AsyncTask<URL, Integer, Long>
{
protected void onPreExecute()
{
dialog=MyProgressDialog.show(getParent(), null,null);
}
@Override
protected Long doInBackground(URL... arg0) {
try{
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpGet httpPost = new HttpGet(DataUrls.map);
HttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity httpEntity = httpResponse.getEntity();
String response = EntityUtils.toString(httpEntity);
}catch(Exception e){
e.printStackTrace();
}
return null;
}
protected void onPostExecute(Long result) {
try{
Map_ExpandableAdapter mNewAdapter = new Map_ExpandableAdapter(MapViewActivity.this,groupItem, childItem,lstMenus,places);
mNewAdapter.setInflater((LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE),MapViewActivity.this);
lstMenus.setAdapter(mNewAdapter);
// lstMenus.setOnChildClickListener(MapViewActivity.this);
UtilsListViewHeight.setListViewHeightBasedOnChildren(lstMenus);
}catch(Exception e)
{
e.printStackTrace();
}
dialog.dismiss();
}
}//closing asynchronous process
这是我正在使用的进度对话框
public class MyProgressDialog extends Dialog {
public static MyProgressDialog show(Context context, CharSequence title,
CharSequence message) {
return show(context, title, message, false);
}
public MyProgressDialog(Context context) {
super(context, R.style.NewDialog);
}
}
在 asynctask 类中我传递了实例 getParent(),因为我正在使用标签。但是我得到了这样的错误
原因:android.view.WindowManager$BadTokenException: Unable to add window -- token android.os.BinderProxy@441cf040 无效;您的活动正在进行吗?
所以请告诉我这是什么问题。感谢所有 InAdvanced
【问题讨论】:
标签: android android-asynctask progressdialog