안녕하세요?
AlertDialog 구현중 궁금한 점이 있어 올립니다.
현재 main activity 에 간단히 아래와 같이 구현 해 놓은 상태 입니다.
@Override
protected Dialog onCreateDialog(int i) {
Dialog dialog;
switch (i) {
case DIALOG_AUTHENTICATION:
dialog = new AlertDialog.Builder(ConnectorActivity.this).setTitle("Select Option")
.setSingleChoiceItems(R.array.select, 0, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,int which) {
}
}).setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
}
}).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
}
}).create();
break;
default:
dialog = null;
}
return dialog;
}
main activity 상에서 아래와 같이 호출 했을 때 alertDialog 가 잘 동작 되는 것은 확인 하였습니다.
Button DialogTestButton = (Button) findViewById(R.id.dialog);
DialogTestButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Dialog dialog = onCreateDialog(DIALOG_AUTHENTICATION);
dialog.show();
}
});
그런데, 실제 이 dialog 가 호출 되어야 하는 시점은, 따로 돌고 있는 thread 상에서 어떤 외부 이벤트를 받았을 때 입니다.
이때 어떻게 저 dialog 를 사용 할 수 있는지 궁금합니다.
답변 부탁 드립니다.
thread를 돌고 있을 때 이벤트가 들어온것을 알 수 있는 flag값을 세팅해 주시고
그 이벤터그 들어올시 thread를 stop하시고 dialog를 띄워주시면 되지 않을까요?
alert이 떠도 thread는 계속 돌아야 하는 것인가요?