android App 이 죽어도 CountDown 이 계속 진행되게 하는 것좀 알려주세요.
Timer 만들어 봤는데요. Activity를 이동하거나 꺼지면 첨부터 다시 시작하더라구요. 근대 android 시간으로 1시간 지나면 다른 이벤트가 발생하게 하려고 하는데 방법이 없을까요?
package com.example.demoproject;
import android.app.Activity;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TextView;
import android.widget.Toast;
public class TimerMainActivity extends Activity {
TextView Timer;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_timer_main);
Timer = (TextView) findViewById(R.id.Timer);
CountDownTimer mCountDown = null;
mCountDown = new CountDownTimer(3599999,10) {
@Override
public void onTick(long millisUntilFinished) {
// TODO Auto-generated method stub
Timer.setText("남은 시간 : " + millisUntilFinished / 10);
// Toast.makeText(getApplicationContext(), "남은 시간: " + millisUntilFinished / 1000, 2500).show();
}
@Override
public void onFinish() {
// TODO Auto-generated method stub
Toast.makeText(getApplicationContext(), "종료되었습니다.", 1000).show();
}
}.start();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.timer_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}