제가 메스 알람인가 보고 똑같이 해볼려고 하는데
알람이 울릴시 조건 을 만족 하지 않으면 알람이 계속 울림니다.
하지만 홈키 누르고 실행중 프로그램 종료 해버리면 종료가 되버더라고요
이걸 방지할려고 홈키 누르면 프로그램 실행중인걸 안보이게 해버렸던데
이건 어떻게 해야하는거져
static public int quiz_random;
boolean lock;
TextView text_question;
TextView text_quiz_count;
EditText text_answer;
int quiz_count;
int quiz_now;
String ans;
TextView text_now_day;
TextView text_now_time;
Handler handler = new Handler();
Runnable runnable = new Runnable() { public void run(){ update_time(); } };
public void update_time(){
text_now_day.setText( now_day.get() );
text_now_time.setText( now_time.get() );
handler.postDelayed( runnable, define.SEC );
}
public void gen_quiz(){
quiz_random = ( int )( Math.random() * ( quiz_common_list.length - 1 ) );
text_question.setText( quiz_common_list[ quiz_random ].question );
}
public void update_count(){
text_quiz_count.setText( quiz_now + " / " + quiz_count );
}
public void update_quiz(){
if( ++quiz_now > quiz_count ){ // 알람 종료
lock = false;
finish();
}
else{
update_count();
gen_quiz();
}
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.page_quiz_3);
lock = true;
text_now_day = ( TextView )findViewById( R.id.now_day );
text_now_time = ( TextView )findViewById( R.id.now_time );
update_time();
quiz_count = getIntent().getIntExtra( "quiz_count", 1 );
quiz_now = 1;
text_question = ( TextView )findViewById( R.id.quiz_3_question );
text_question.setTextColor( Color.YELLOW );
text_question.setTextSize( 30 );
gen_quiz();
text_quiz_count = ( TextView )findViewById( R.id.quiz_3_count );
update_count();
text_answer = ( EditText )findViewById( R.id.quiz_3_answer );
( ( ImageView )findViewById( R.id.quiz_3_ok ) ).setOnClickListener( new OnClickListener(){
@Override
public void onClick(View v) {
try{
if( text_answer.getText().toString().equals(
quiz_common_list[ quiz_random ].answer ) ){
update_quiz();
}
}
catch( Exception e ){
}
text_answer.getText().clear();
}
});
if( null == media_player ){
int sound_id = getIntent().getIntExtra( "sound_id", 0 );
if( 0 != sound_id ){
media_player = MediaPlayer.create( this, sound_id );
media_player.start();
media_player.setOnCompletionListener( new OnCompletionListener(){
@Override
public void onCompletion(MediaPlayer mp) {
media_player.start();
}
});
}
}
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
switch( keyCode ){
case KeyEvent.KEYCODE_BACK:
case KeyEvent.KEYCODE_HOME:
return false;
}
return super.onKeyDown(keyCode, event);
}
@Override
protected void onDestroy() {
super.onDestroy();
if( lock ){
startActivity( new Intent( page_quiz_3.this, page_quiz_3.class ) );
}
else{
if( null != media_player ){
media_player.release();
media_player = null;
}
}
}
여기서 어떻게 수정 하면 될까요