2014-09-23 46 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部分实现它。

相关问题