알람 매니저게 알람 등록 하기
Calendar calendar = Calendar.getInstance(); // 현재 시간
calendar.add(Calendar.SECOND, 10);
Intent alramIntent = new Intent(this(PackageContext), .AlramReceiver.class);
PendingIntent pIntent = PendingIntent.getBroadcast(this(Context), 0(고유 숫자), alramIntent, PendingIntent.FLAG_CANCEL_CURRENT);
AlarmManager am = (AlarmManager)getSystemService(ALARM_SERVICE);
if(null != am) {
am.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), pIntent);
}
calendar.add(Calendar.SECOND, 10);
Intent alramIntent = new Intent(this(PackageContext), .AlramReceiver.class);
PendingIntent pIntent = PendingIntent.getBroadcast(this(Context), 0(고유 숫자), alramIntent, PendingIntent.FLAG_CANCEL_CURRENT);
AlarmManager am = (AlarmManager)getSystemService(ALARM_SERVICE);
if(null != am) {
am.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), pIntent);
}
Receiver Class 생성
public class AlramReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { } }
AndroidManifest.xml에 application 안에 아래 코드 삽입
<receiver android:name=".AlramReceiver" />;
댓글 없음:
댓글 쓰기