gpt4 book ai didi

android - onActivityResult ResultCode 始终为 0

转载 作者:太空宇宙 更新时间:2023-11-03 10:59:43 25 4
gpt4 key购买 nike

我总是用下面的代码得到 ResultCode = 0
这是我处理setResult

的代码
  @Override
public void onResponse(Call<ResponseBody> call, retrofit2.Response<ResponseBody> response) {
Debug.i("Response Status Complete " + response.code());
if (response.code() == 200) {
Debug.i("Response Status Complete " + response);

mSectionTopic.isComplete = 1;
mSectionTopic.status = "completed";

Intent intent = new Intent();
intent.putExtra(Util.getIntentName("sectionTopic"), mSectionTopic);
intent.putExtra(Util.getIntentName("challengeId"), "AIzaSyBkSGK9geQ4QbnvXcQQ_m2JScd7r89xnJs");
intent.putExtra(Util.getIntentName("position"), mPosition);

setResult(Activity.RESULT_OK, intent);
finish();

} else {
showError(getString(R.string.text_post_question_failed));
}

但是如果代码 onBackPressed(); resultcode 工作正常。

我的代码有什么问题?

--

这是我的onActivityResult()

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == REQ_CODE && resultCode == Activity.RESULT_OK) {
if (data == null) return;
int position = data.getIntExtra(Util.getIntentName("position"), 0);
mAdapter.setComplete(position);
mAdapter.notifyDataSetChanged();

}
}

最佳答案

您需要正确实现 startActivityForResult()onActivityResult()。按照此处的说明进行操作 - Transfer data between two activities

关于android - onActivityResult ResultCode 始终为 0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46971870/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com