當前位置: 首頁>>代碼示例>>Java>>正文


Java AlarmManager.ELAPSED_REALTIME_WAKEUP屬性代碼示例

本文整理匯總了Java中android.app.AlarmManager.ELAPSED_REALTIME_WAKEUP屬性的典型用法代碼示例。如果您正苦於以下問題:Java AlarmManager.ELAPSED_REALTIME_WAKEUP屬性的具體用法?Java AlarmManager.ELAPSED_REALTIME_WAKEUP怎麽用?Java AlarmManager.ELAPSED_REALTIME_WAKEUP使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在android.app.AlarmManager的用法示例。


在下文中一共展示了AlarmManager.ELAPSED_REALTIME_WAKEUP屬性的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: restartApplication

/**
 * 重啟App
 *
 * @param context application
 * @param delay   當前App被殺死之後,延遲多久重新啟動。
 */
public static void restartApplication(Context context, int delay) {
    Intent intent = context.getPackageManager()
            .getLaunchIntentForPackage(context.getPackageName());
    PendingIntent restartIntent = PendingIntent.getActivity(context.getApplicationContext(), 0
            , intent, PendingIntent.FLAG_ONE_SHOT);
    AlarmManager mgr = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
    int type = AlarmManager.ELAPSED_REALTIME_WAKEUP;
    long triggerTime = SystemClock.elapsedRealtime() + delay;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        mgr.setExact(type, triggerTime, restartIntent);
    } else {
        mgr.set(type, triggerTime, restartIntent);
    }
    Process.killProcess(Process.myPid());
}
 
開發者ID:aesean,項目名稱:ActivityStack,代碼行數:21,代碼來源:ApplicationUtils.java

示例2: doSchedule

private synchronized int doSchedule(int entryId, int intervalMs) {
	//Log.d(THIS_FILE, "SCHED add " + entryId + " in " + intervalMs);
       long firstTime = SystemClock.elapsedRealtime();
       // Clamp min
       if(intervalMs < 10) {
           firstTime +=  10;
       }else {
           firstTime += intervalMs;
       }
       
	PendingIntent pendingIntent = getPendingIntentForTimer(entryId, firstTime);
	
	
	// If less than 1 sec, do not wake up -- that's probably stun check so useless to wake up about that
	//int alarmType = (intervalMs < 1000) ? AlarmManager.ELAPSED_REALTIME : AlarmManager.ELAPSED_REALTIME_WAKEUP;
	int alarmType = AlarmManager.ELAPSED_REALTIME_WAKEUP;
	
	// Cancel previous reg anyway
	alarmManager.cancel(pendingIntent);
	int existingReg = scheduleEntries.indexOf((Integer) entryId);
	if(existingReg != -1) {
	    scheduleEntries.remove(existingReg);
	    scheduleTimes.remove(existingReg);
	}
	
	// Push next
       Log.v(THIS_FILE, "Schedule timer " + entryId + " in " + intervalMs + "ms @ " + firstTime);
       Compatibility.setExactAlarm(alarmManager, alarmType, firstTime, pendingIntent);
	scheduleEntries.add((Integer) entryId);
       scheduleTimes.add((Long) firstTime);
	return 1;
}
 
開發者ID:treasure-lau,項目名稱:CSipSimple,代碼行數:32,代碼來源:TimerWrapper.java

示例3: scheduleSystemAlarm

private void scheduleSystemAlarm() {
    alarmPendingIntent = PendingIntent.getActivity(this, 0, new Intent(this, SummaryActivity.class), PendingIntent.FLAG_CANCEL_CURRENT);
    int type = AlarmManager.ELAPSED_REALTIME_WAKEUP;
    long trigger = SystemClock.elapsedRealtime() + COUNTDOWN_DURATION;

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
        alarmManager.setExactAndAllowWhileIdle(type, trigger, alarmPendingIntent);
    else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT)
        alarmManager.setExact(type, trigger, alarmPendingIntent);
    else
        alarmManager.set(type, trigger, alarmPendingIntent);
}
 
開發者ID:gvinciguerra,項目名稱:custode,代碼行數:12,代碼來源:PinCountdownActivity.java


注:本文中的android.app.AlarmManager.ELAPSED_REALTIME_WAKEUP屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。