当前位置: 首页>>代码示例>>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;未经允许,请勿转载。