Calendar firingCal = Calendar.getInstance();
Intent myInten = new Intent(Report_Activity.this, MyReceiver.class);
final int intent_id_two = (int) System.currentTimeMillis();
Calendar now = Calendar.getInstance();
AlarmManager alarmManager = (AlarmManager) Report_Activity.this.getSystemService(Report_Activity.ALARM_SERVICE);
PendingIntent myPendingIntent = PendingIntent.getBroadcast(Report_Activity.this, intent_id_two, myInten, PendingIntent.FLAG_CANCEL_CURRENT);
firingCal.set(Calendar.HOUR_OF_DAY, 00);
firingCal.set(Calendar.MINUTE, 01);
firingCal.set(Calendar.SECOND, 0);
if (firingCal.compareTo(now) < 0) {
firingCal.add(Calendar.DAY_OF_MONTH, 1);
myInten.setFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
Bundle bundle = new Bundle();
bundle.putString("date", str_view_date);
bundle.putString("time", str_view_time);
bundle.putString("school_name", str_show_school_name);
bundle.putInt("intent_id", intent_id_two);
myInten.putExtras(bundle);
alarmManager.setRepeating(AlarmManager.RTC, firingCal.getTimeInMillis(),AlarmManager.INTERVAL_DAY, myPendingIntent);
} else {
myInten.setFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
Bundle bundle = new Bundle();
bundle.putString("date", str_view_date);
bundle.putString("time", str_view_time);
bundle.putString("school_name", str_show_school_name);
bundle.putInt("intent_id", intent_id_two);
myInten.putExtras(bundle);
alarmManager.setRepeating(AlarmManager.RTC, firingCal.getTimeInMillis(),AlarmManager.INTERVAL_DAY, myPendingIntent);
}
}
,这里是我的接收机类我想设置我的通知闹钟在第二天上午9点左右,但我不能够集
int num = (int) System.currentTimeMillis();
Bundle bundle = intent.getExtras();
date = bundle.getString("date");
time = bundle.getString("time");
school_name = bundle.getString("school_name");
// int notifyId = 1;
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
Intent notificationIntent = new Intent(context, MainActivity.class);
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
//final int intent_id = (int) System.currentTimeMillis();
pendingIntent = PendingIntent.getActivity(context, num, notificationIntent, 0);
Uri alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
builder.setContentTitle("Notification From Dextro");
builder.setContentText("Meeting Schedule at " + school_name + " on " + date + " and time is " + time);
builder.setSmallIcon(R.mipmap.dextro_customerlogo);
builder.setContentIntent(pendingIntent);
builder.setAutoCancel(true);
builder.setSound(alarmSound);
builder.setTicker("Notification From Dextro");
builder.setStyle(new NotificationCompat.BigTextStyle()
.bigText("Meeting Schedule at " + school_name + " on " + date + " and time is " + time));
builder.setVibrate(new long[]{100, 100, 100, 100});
notificationManager.notify(num, builder.build());
//notifyId++;
}
我想设置在第二天通知,但我无法接收但是当我为今天设置闹钟然后我收到notification.What我应该改变我this.If我设置在24小时范围内的警报,然后我收到通知,但是当我第二天去设置闹钟然后它没有收到请推荐我..
请帮助我,我只希望我怎样才能在状态栏 – Sushil