안드로이드 폰갭 프로그램 종료제어 문제
목적: 안드로이드 기반 폰갭 앱에서 뒤로가기 버튼을 2번눌러야지만 앱 종료
아래 코드는
DroidGap상속받은 MainActivity의 onBackPressed메소드가 호출될 때의 코드입니다.
-----------------------------------------------------------------------------------------------
@Override
public void onBackPressed() {
Builder dlog = new AlertDialog.Builder(this);
dlog.setMessage("정말 종료?");
dlog.setPositiveButton("예", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
finish();
}
});
dlog.setNegativeButton("아니요", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
dlog.show();
}
-----------------------------------------------------------------------------------------------
위 코드대로 다이로그가 뜨긴 하지만, 앱종료도 같이 되버리더군요.
결과적으로, 저 코드는 의미가 없게 되버렸내요. -_-;
제가 뭘 빠뜨렸을텐데, 뭘 빠뜨렸을까요?
(프로젝트파일 파일첨부 있습니다)
첨부 | 파일 크기 |
---|---|
PhoneGapTest.zip | 3.35 MB |
댓글 달기