私は非常に多くの質問と回答を見てきましたが、私が見つけたもののどれも実際に働いていませんでした!AsyncTaskは必ずしも呼び出すとは限りませんが、そうであればnullになりますか?
基本的にタイトルがあまり役に立たないなら、私がやろうとしていることはダイアログからAsyncTaskを実行することですが、実行していないときにはnullオブジェクトとして表示されます。それは血の迷惑なのですね。
だれでも助けてくれればそれはすばらしいことでしょう。
クラスはサブベッドです。
ここで非同期クラスです:
String oldPassword = changePassOld.getText().toString();
String newPassword = changePassNew.getText().toString();
AsyncTask task = new UpdatePassword(oldPassword, newPassword, ProfileFragment.this.getContext());
task.execute();
編集を:私は私が唯一doInBackground
を持っていることに気づいたが、私はpreExecute
を持っていた場合でも、
static class UpdatePassword extends AsyncTask<String, String, String> {
Context context;
String oldPassword;
String newPassword;
public UpdatePassword(String setOldPassword, String setNewPassword, Context context) {
this.oldPassword = setOldPassword;
this.newPassword = setNewPassword;
this.context = context;
}
@Override protected String doInBackground(String... params) {
HttpRequestUtils httpRequestUtils = new HttpRequestUtils(context);
if (TextUtils.isEmpty(oldPassword) || TextUtils.isEmpty(newPassword)) {
return null;
} else {
String response = null;
String baseUrl = "rest/ws/user/update/password";
ApiResponse apiResponse = null;
try {
response = httpRequestUtils.getResponse(baseUrl + "?oldPassword=" + oldPassword + "&newPassword=" + newPassword, "application/json", "application/json");
if (TextUtils.isEmpty(response)) {
return null;
}
apiResponse = (ApiResponse) GsonUtils.getObjectFromJson(response, ApiResponse.class);
if (apiResponse != null && apiResponse.isSuccess()) {
return apiResponse.getStatus();
}
Log.i("Update", "password call" + apiResponse);
} catch (Exception e) {
e.printStackTrace();
}
return newPassword;
}
}
}
そして、ここでは、私はそれを実行するためにやってんですよそれでも動作しませんでした。
をAsyncTaskの
onPostExecute
を実装するには、あなたの 'postExecute()'メソッドをデバッグしていますか? 'doInBackground'から何の返答もないことを確信していますか? –ええ、何も返しません。 – user3125867
あなたの問題は間違いなく' doInBackground'本体にあります。ヌルを返してデバッグし、 –