public void alarm() {
new CountDownTimer(3 * 1000, 1000) { //更新密度(秒)
public void onFinish() {
// TODO Auto-generated method stub
Time mTime=new Time(); // or Time t=new Time("GMT+8"); 加上Time Zone资料。
mTime.setToNow(); // 取得系统时间。
int year = mTime.year;
int month = mTime.month;
int date = mTime.monthDay;
int hour =mTime.hour; // 0-23
int minute = mTime.minute;
int second =mTime.second;
if(hour==1 && minute==56)
Toast.makeText(getApplicationContext(), "默认Toast样式",
Toast.LENGTH_SHORT).show();
alarm();
}
@Override
public void onTick(long arg0) {
// TODO Auto-generated method stub
}
}.start();
}
--------------------------------------------------------------------------------
package com.example.iftest;
import android.app.Service;
import android.content.Intent;
import android.os.CountDownTimer;
import android.os.IBinder;
import android.text.format.Time;
import android.widget.Toast;
public class sv extends Service {
public void alarm() {
new CountDownTimer(3 * 1000, 1000) { //更新密度(秒)
public void onFinish() {
// TODO Auto-generated method stub
Time mTime=new Time(); // or Time t=new Time("GMT+8"); 加上Time Zone资料。
mTime.setToNow(); // 取得系统时间。
int year = mTime.year;
int month = mTime.month;
int date = mTime.monthDay;
int hour =mTime.hour; // 0-23
int minute = mTime.minute;
int second =mTime.second;
if(hour==1 && minute==56)
Toast.makeText(getApplicationContext(), "默认Toast样式",
Toast.LENGTH_SHORT).show();
alarm();
}
@Override
public void onTick(long arg0) {
// TODO Auto-generated method stub
}
}.start();
}
@Override
public IBinder onBind(Intent intent) {
// TODO Auto-generated method stub
return null;
}
@Override
public void onCreate() {
alarm();
}
}
--------------------------------------------------------------------------------------------
Alarm, service,
沒有留言:
張貼留言