开发者

Android notifications delay

开发者 https://www.devze.com 2023-03-15 14:50 出处:网络
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:

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消