I'm making a notification in android, but I have a small delay before the notification appears - is this norm开发者_运维百科al? Here is my code:
final int REQUEST_CODE = 1;
Intent intent = new Intent(Add_Assignment.this, Assignment_AlarmReceiver.class);
//Bundle stuff omitted for brevity
PendingIntent pendingIntent =
PendingIntent.getBroadcast(Add_Assignment.this, REQUEST_CODE, intent, 0);
AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
alarmManager.set(AlarmManager.RTC_WAKEUP,
System.currentTimeMillis() + (5 * 1000), pendingIntent);
Toast.makeText(Add_Assignment.this, "Alarm set", Toast.LENGTH_LONG).show();
System.currentTimeMillis() + (5 * 1000)
means 5
seconds
from now
.
精彩评论