2015-10-13 80 views

回答

0

使用AlarmManager。它允許您在指定的時間內發送意圖。

Intent startIntent = new Intent("WhatEverYouWant"); 
PendingIntent startPIntent = PendingIntent.getBroadcast(context, 0, startIntent, 0); 
AlarmManager alarm = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); 
alarm.set(AlarmManager.RTC_WAKEUP, triggerTime, startPIntent); 

在清單文件中,添加接收器時採用與Intent中相同的操作。並從接收器中顯示通知。使用AlarmManager這裏
https://developer.android.com/reference/android/app/AlarmManager.html#set(int, long, android.app.PendingIntent)

發送意向書

<receiver android:name="com.package.YourOnReceiver"> 
    <intent-filter> 
     <action android:name="WhatEverYouWant" /> 
    </intent-filter> 
</receiver> 

更多信息