요청 코드를 사용하여 MainActivity
에서 InfomationActivity
으로 전화했습니다. 그러나 MainActivity
을 반환하면 비활성 상태가됩니다. 여기에 어떤 문제가 있습니까?ResultCode 및 RequestCode가 작동하지 않습니다.
MainActivity
에서
하는 requestCode가 사용 InfomationActivity
전화 : InfomationActivity
에서
Intent intent = new Intent(MainActivity.this, InfomationActivity.class);
startActivityForResult(intent, 100);
을하는 같은 ResultCode 반환 :
if(btnAlarmInfo.getVisibility() == View.VISIBLE){
//run
Log.d("abc", note.getTitle() + "/" + note.getNote() + "/" + note.getDateTime() + "/" + note.getColorBackground());
Log.d("abc", Integer.toString(images.size()));
Intent intent = getIntent();
intent.putExtra("title", note.getTitle());
intent.putExtra("note", note.getNote());
intent.putExtra("time", note.getDateTime());
intent.putExtra("color", note.getColorBackground());
intent.putParcelableArrayListExtra("image", images);
setResult(3, intent);
finish();
}else{
//run
Intent intent = getIntent();
intent.putExtra("title", note.getTitle());
intent.putExtra("note", note.getNote());
intent.putExtra("time", note.getDateTime());
intent.putExtra("color", note.getColorBackground());
intent.putExtra("day", note.getDayAlarm());
intent.putExtra("hour", note.getHourAlarm());
intent.putParcelableArrayListExtra("image", images);
setResult(4, intent);
finish();
}
그리고 때를 MainActivity
반환 :
if(requestCode == 100){
if(resultCode == 3){
//not run ????????
Log.d("abc", "it's me");
String title = data.getExtras().getString("title");
String note = data.getExtras().getString("note");
String time = data.getExtras().getString("time");
String color = data.getExtras().getString("color");
ArrayList<Image> image = data.getParcelableArrayListExtra("image");
Log.d("abc", Integer.toString(image.size()));
ArrayList<Bitmap> bitmaps = new ArrayList<Bitmap>();
for(int i = 0; i < image.size(); i++){
bitmaps.add(image.get(i).getImage());
}
Note note1 = new Note(title, note, false, time, color, "", "", bitmaps);
this.addNote(note1);
}else if(resultCode == 4){
//run
String title = data.getExtras().getString("title");
String note = data.getExtras().getString("note");
String time = data.getExtras().getString("time");
String color = data.getExtras().getString("color");
String day = data.getExtras().getString("day");
String hour = data.getExtras().getString("hour");
ArrayList<Image> image = data.getParcelableArrayListExtra("image");
ArrayList<Bitmap> bitmaps = new ArrayList<Bitmap>();
for(int i = 0; i < image.size(); i++){
bitmaps.add(image.get(i).getImage());
}
Note note1 = new Note(title, note, true, time, color, day, hour, bitmaps);
this.addNote(note1);
}
}
, 난 resultcode = 3 일 때 실행되지 않는지 확인하십시오. 왜 resultcode = 3이면 실행되지 않습니까?
과 4, 괜찮습니다. –
정수 값은이 결과에 적용 할 수 없으므로 비정상적으로 작동 할 수 있으므로 RESULT_OK 만 사용하고 3 또는 4를 int로 사용하여 하나의 매개 변수를 설정하는 것이 좋습니다. 중요한 것은 모든 값을 입력 할 필요가 없습니다. if-else loop 그래서 시도해보십시오. – Vickyexpert
2 건이 처리되면 괜찮습니다.하지만 더 많은 경우가 필요합니까 ??? –