public String getCurrentTime(){
Calendar c= Calendar.getInstance();
Log.i("Calander getinstance",Calendar.getInstance()+"");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss ");
String strDate = sdf.format(c.getTime());
return strDate;
}
public void alert()
{
Calendar cal = Calendar.getInstance();
Intent myIntent = new Intent(MainActivity.this, myReceiver.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(MainActivity.this, 0, myIntent,0);
AlarmManager alarmManager = (AlarmManager)getSystemService(ALARM_SERVICE);
alarmManager.set(AlarmManager.RTC,Long.parseLong(getCurrentTime()), pendingIntent);
}
在getCurrentTime,它必須返回的字符串,但可以alarmManager.set得到字符串
alarmManager.set(AlarmManager.RTC,Long.parseLong(getCurrentTime()), pendingIntent); is only get for Long. Is that Another way. Help Plz.
爲什麼ü想串花花公子 –
PHP返回 「YYYY-MM-DD HH:MM:SS」 格式。字符串返回。所以,我把當前時間改成這種格式。如果鬧鐘管理器只有很長時間,我會遇到問題。 – vcav
對不起。我看不到你的答案。它在哪裏? – vcav