3
A
回答
9
顯然你應該使用AlarmManager來設置在給定PERIOD中執行的東西。
AlarmManager mgr = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
Intent i = new Intent(context, OnAlarmReceiver.class);
PendingIntent pi = PendingIntent.getBroadcast(context, 0, i, 0);
mgr.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,
SystemClock.elapsedRealtime(), PERIOD, pi);
其中週期是你的時間的東西,應該在OnAlarmReceiver執行。 然後,只需實施方法
@Override
public void onReceive(Context context, Intent intent) {
NotificationManager nm = (NotificationManager);
context.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new Notification();
notification.tickerText = "10 Minutes past";
nm.notify(0, notification);
}
享受。
2
你應該使用AlarmManager
。有了它,您可以安排意向交付。創建一個BroadcastReceiver
以獲取並顯示通知。
1
Somethink like this我猜你在10分鐘後啓動一個runnable並在runnable的代碼中打開一個通知。
Runnable reminder = new Runnable()
{
public void run()
{
int NOTIFICATION_ID = 1324;
NotificationManager notifManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
Notification note = new Notification(R.drawable.icon, "message", System.currentTimeMillis());
// Add and AUTO_CANCEL flag to the notification,
// this automatically removes the notification when the user presses it
note.flags |= Notification.FLAG_AUTO_CANCEL;
PendingIntent i = PendingIntent.getActivity(this, 0, new Intent(this, ActivityToOpen.class), 0);
note.setLatestEventInfo(this, "message", title, i);
notifManager.notify(NOTIFICATION_ID, note);
}
};
Handler handler = new Handler();
handler.postDelayed(reminder, 600000);
相關問題
- 1. android提醒
- 2. 使自定義Android提醒提醒
- 3. 在android的提醒
- 4. ANDROID刪除提醒
- 5. Android:每日提醒
- 6. Android提醒意向
- 7. Android臨近提醒
- 8. Android:設置提醒功能
- 9. 簡單的提醒爲Android
- 10. Android提醒應用程序
- 11. 時間提醒問題 - Android
- 12. Android應用程序提醒
- 13. Android通知提醒用戶
- 14. Android對話框提醒
- 15. Android的提醒應用
- 16. 提醒
- 17. 聊天消息提醒,如Gmail提醒
- 18. Android提醒對話框數字輸入
- 19. 關於android的提醒通知
- 20. 顯示Android提醒黑色背景
- 21. 用於提醒人們的Android AutoCompleteTextView
- 22. Android:計算時間來設置提醒
- 23. Android:爲日曆事件設置提醒
- 24. Android中的鬧鐘/提醒聲音
- 25. Android「別再問我」提醒對話框
- 26. Android自定義日曆和提醒
- 27. Android日曆提醒事件問題
- 28. 添加提醒日曆的Android
- 29. android中的自定義提醒框
- 30. Android智力競賽留言提醒
寫了一個教程。通知提醒:http://blog.blundell-apps.com/notification-for-a-user-chosen-time/ – Blundell 2012-02-21 13:21:50