2014-09-23 70 views

回答

0

是的。在Android上,這樣對每實時時鐘安排喚醒:

private static final long WINDOW_MS = 50L; // Allow some time flexibility to save battery power. 

AlarmManager alarmMgr = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE); 
PendingIntent pendingIntent = makeAlarmPendingIntent(context); 
long nextReminder = ... // the SystemClock.elapsedRealtime() for the next reminder notification 
alarmMgr.setWindow(AlarmManager.ELAPSED_REALTIME_WAKEUP, nextReminder - WINDOW_MS, 
        WINDOW_MS, pendingIntent); 

隨着BroadcastReceiver獲得這個pendingIntent。當相關的Intent到達時,使用Notification播放聲音。見NotificationCompat.Builder及其setSound()方法。

Cordova可能會提供所需的API來執行此操作。如果沒有,你必須在應用程序的Java部分實現它。

相關問題