我正在尝试调用 Web 服务,但单击按钮时没有发生任何事情。我正在使用 activtygroup 我尝试了两种类型的上下文子项和父项,但它不起作用。它显示WindowManagerBadTokenException。
这是我调用webservice的代码:
//GET USER WEBSERVICE
public void callUpdateUserInfo_WS() {
if (NetworkAvailablity.checkNetworkStatus(ProfileScreen.this)) {
// PREPARE URL
Constant.methodURL = "http://admin.tvdevphp.com/goalmachine/update_profile.php";
// PREPARE REQUEST PARAMETER
ArrayList<NameValuePair> requestParaList = new ArrayList<NameValuePair>();
requestParaList.add(new BasicNameValuePair("user_id", "1"));
requestParaList.add(new BasicNameValuePair("first_name", "Ricky"));
requestParaList.add(new BasicNameValuePair("age", "0"));
requestParaList.add(new BasicNameValuePair("age_visible", "Yes"));
requestParaList.add(new BasicNameValuePair("parental_status", "Yes"));
requestParaList.add(new BasicNameValuePair("parental_status_visible", "Yes"));
requestParaList.add(new BasicNameValuePair("marital_status", "Single"));
requestParaList.add(new BasicNameValuePair("marital_status_visible", "No"));
requestParaList.add(new BasicNameValuePair("short_bio", "Hard working"));
requestParaList.add(new BasicNameValuePair("short_bio_visible", "Yes"));
requestParaList.add(new BasicNameValuePair("country", "India"));
requestParaList.add(new BasicNameValuePair("country_visible", "Yes"));
requestParaList.add(new BasicNameValuePair("zipcode", "452001"));
requestParaList.add(new BasicNameValuePair("zipcode_visible", "Yes"));
requestParaList.add(new BasicNameValuePair("avatar", ""));
requestParaList.add(new BasicNameValuePair("latest_status_update", "In Indore India."));
requestParaList.add(new BasicNameValuePair("latest_status_update_visible", "Yes"));
requestParaList.add(new BasicNameValuePair("pain_scale", "50"));
requestParaList.add(new BasicNameValuePair("pain_scale_visible", "No"));
// CALL WEBSERVICE
WebServiceCommunicator.getInstance().registerForServerResponse(
(IServerResponse)this.getParent());
WebServiceCommunicator.getInstance().callGetAppWebService(
Constant.showDialog, this.getParent(),
Constant.methodURL, this.getParent(), Constant.PID_UPDATE_USER_INFO,
false, requestParaList);
} else {
Constant.showAlertDialog(Constant.errorTitle,
Constant.MSG_CHECK_INTERNET_SETTING, this.getParent(),
false);
}
}
这是网络服务的东西:
public void callGetAppWebService(final Boolean showProgressBar,
final Context childContext, final String url,
final Context context, final int processid,
final boolean isFinishForFailResponse,
final ArrayList<NameValuePair> requestParaList) {
if (_progressDialog != null && _progressDialog.isShowing()) {
_progressDialog.cancel();
}
if (showProgressBar) {
_progressDialog = ProgressDialog
.show(context, "", "Please wait...");
}
_context = childContext;
_isFinishForFailResponse = isFinishForFailResponse;
new Thread(new Runnable() {
public void run() {
Looper.prepare();
try {
if (NetworkAvailablity.checkNetworkStatus(context)) {
String jsonResponse = WebService.postData(url,
requestParaList);
if (jsonResponse != null && jsonResponse.length() != 0) {
strResponse = jsonResponse;
Log.v("response", strResponse);
}
} else {
}
} catch (Exception e) {
// DebugLog.LOGE("Exception from callWebService():" +
// e.toString());
}
if (showProgressBar)
_progressDialog.cancel();
handleResponse(strResponse, processid);
}
}).start();
}