난 이상한, 왜 여분의 불리언 넣어 후 잘못된 값을 가지고. 엄청 이상해. 나는 다른 게시물에 대해 이미 여분의 넣어에 대한 답변을 알고 있지만이 게시물은 내가 왜 잘못 된 가치를 모르겠어요.안드로이드에 여분의 boolen 넣어 잘못된 값을
이것은 첫 번째 활동입니다. 그냥 짧은 코드. 당신은 항상 false
를 얻을 수 있도록
btnActivity.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent i = new Intent(getApplicationContext(), ActivitySecond.class);
startActivityForResult(i, 1);
}
});
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(requestCode==1)
{
boolean thisAnwser = getIntent().getBooleanExtra("thisAnwserBoolean",false);
Log.i("this boolean is","Answer: "+thisAnwser); //this log, i got false..
if(thisAnwser){
Log.i("Good this true","yes");
}
}
}
이, 두 번째 활동
Intent intent = new Intent();
intent.putExtra("thisAnwserBoolean", true); // when i try log, i got true.
setResult(1,intent);
finish();
을 당신은 잘못된'Intent' 찾고 있습니다. onActivityResult() 메소드의 Intent data 매개 변수에서 추가 정보를 얻고 싶습니다. –
네, 맞습니다 .. 감사합니다. –
'Bundle extra = data.getExtras(); 부울 thisAnwser = extra.getBoolean ("thisAnwserBoolean"); 또는 부울 thisAnwser = data.getExtras() getBoolean ("thisAnwserBoolean");. ' –