마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

android App 이 죽어도 CountDown 이 계속 진행되게 하는 것좀 알려주세요. 기기 내에서 시간

0 추천

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);
	}
}

 

바밥 (420 포인트) 님이 2015년 5월 11일 질문

2개의 답변

0 추천
android service로 구글링하세요
쎄미 (162,410 포인트) 님이 2015년 5월 12일 답변
0 추천
알람을 쓰시면 되겠네여
Gradler (109,780 포인트) 님이 2015년 5월 12일 답변
...