当前位置: 首页>>代码示例>>Java>>正文


Java AlarmManager.setExact方法代码示例

本文整理汇总了Java中android.app.AlarmManager.setExact方法的典型用法代码示例。如果您正苦于以下问题:Java AlarmManager.setExact方法的具体用法?Java AlarmManager.setExact怎么用?Java AlarmManager.setExact使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.app.AlarmManager的用法示例。


在下文中一共展示了AlarmManager.setExact方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onReceive

import android.app.AlarmManager; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent mintent) {
	//if (Intent.ACTION_BOOT_COMPLETED.equals(mintent.getAction())) {  
           // 启动完成  
	Log.i("BootReceiver", "onReceive");
           Intent intent = new Intent(context, AlarmReceiver.class);  
           intent.setAction(AlarmReceiver.ACTION);  
           PendingIntent sender = PendingIntent.getBroadcast(context, 0,  
                   intent, 0);  
           AlarmManager am = (AlarmManager) context  
                   .getSystemService(Context.ALARM_SERVICE);  
           if(android.os.Build.VERSION.SDK_INT<android.os.Build.VERSION_CODES.KITKAT){
			/** 开机激活闹钟 **/
           	am.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis()+60000, sender);
		}
		else{
			am.setExact(AlarmManager.RTC_WAKEUP, System.currentTimeMillis()+60000, sender);
		}
      // }  
}
 
开发者ID:LingjuAI,项目名称:AssistantBySDK,代码行数:21,代码来源:BootReceiver.java

示例2: restartApplication

import android.app.AlarmManager; //导入方法依赖的package包/类
/**
 * 重启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,代码行数:22,代码来源:ApplicationUtils.java

示例3: scheduleNextScan

import android.app.AlarmManager; //导入方法依赖的package包/类
private void scheduleNextScan(Context context) {
    SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context);
    int scanInterval = Integer.parseInt(settings.getString("pref_scaninterval", "300")) * 1000;
    if (scanInterval < 15 * 1000) scanInterval = 15 * 1000;
    boolean batterySaving = settings.getBoolean("pref_bgscan_battery_saving", false);

    Intent intent = new Intent(context, BackgroundScanner.class);
    PendingIntent sender = PendingIntent.getBroadcast(context, BackgroundScanner.REQUEST_CODE, intent, 0);
    AlarmManager am = (AlarmManager) context
            .getSystemService(ALARM_SERVICE);
    if (!batterySaving) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            am.setExactAndAllowWhileIdle(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + scanInterval, sender);
        }
        else {
            am.setExact(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + scanInterval, sender);
        }
    }
}
 
开发者ID:ruuvi,项目名称:com.ruuvi.station,代码行数:20,代码来源:BackgroundScanner.java

示例4: setNotification

import android.app.AlarmManager; //导入方法依赖的package包/类
private void setNotification(long time) {
    AlarmManager manager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
    Intent intent = new Intent("whut.dongdong.easynote.NOTIFY_BROADCAST");
    intent.putExtra("noteId", noteId);
    PendingIntent pendingIntent = PendingIntent
            .getBroadcast(this, noteId, intent, PendingIntent.FLAG_CANCEL_CURRENT);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        manager.setExactAndAllowWhileIdle(AlarmManager.RTC_WAKEUP, time, pendingIntent);
    } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        manager.setExact(AlarmManager.RTC_WAKEUP, time, pendingIntent);
    } else {
        manager.set(AlarmManager.RTC_WAKEUP, time, pendingIntent);
    }
    ToastUtil.showToast(this, "提醒设置成功");
}
 
开发者ID:StableChen,项目名称:easynote,代码行数:16,代码来源:SetNotificationActivity.java

示例5: snoozeAlarm

import android.app.AlarmManager; //导入方法依赖的package包/类
private void snoozeAlarm() {
    Intent intent = new Intent(this, ConfirmationActivity.class);
    intent.putExtra(ConfirmationActivity.EXTRA_ANIMATION_TYPE,
            ConfirmationActivity.SUCCESS_ANIMATION);
    intent.putExtra(ConfirmationActivity.EXTRA_MESSAGE,
            getString(R.string.alarm_snoozed));
    startActivity(intent);

    Intent alarmActivityIntent = new Intent(this, AlarmActivity.class);
    alarmActivityIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    alarmActivityIntent.putExtra(AlarmActivity.EXTRA_ALARM_COMMAND_BYTES, ParcelPacker.getData(alarmCommand));
    startActivity(alarmActivityIntent);

    PendingIntent alarmPendingIntent = PendingIntent.getActivity(this, 0, alarmActivityIntent, PendingIntent.FLAG_UPDATE_CURRENT);
    AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
    alarmManager.setExact(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + alarmCommand.getSnoozeDuration(), alarmPendingIntent);

    finish();
}
 
开发者ID:matejdro,项目名称:WearVibrationCenter,代码行数:20,代码来源:AlarmActivity.java

示例6: schedule

import android.app.AlarmManager; //导入方法依赖的package包/类
@SuppressLint({"NewApi"})
public static void schedule(Context context) {
    LogInfo.log("zhuqiao", "push service schedule");
    int interval = Math.max(PreferencesManager.getInstance().getPushDistance(), 1);
    long historyTime = PreferencesManager.getInstance().getPushTime();
    LogInfo.log("zhuqiao", "historyTime:" + historyTime);
    if (((long) (interval * 1000)) + historyTime < System.currentTimeMillis()) {
        LogInfo.log("push", "下一次时间小于当前时间,进行容错!!");
        PreferencesManager.getInstance().savePushTime(System.currentTimeMillis());
        historyTime = PreferencesManager.getInstance().getPushTime();
    }
    PendingIntent pending = PendingIntent.getService(context, 152104511, new Intent(context, LetvPushService.class), 268435456);
    AlarmManager alarm = (AlarmManager) context.getSystemService(NotificationCompat.CATEGORY_ALARM);
    alarm.cancel(pending);
    if (VERSION.SDK_INT >= 19) {
        alarm.setExact(0, ((long) (interval * 1000)) + historyTime, pending);
    } else {
        alarm.set(2, ((long) (interval * 1000)) + historyTime, pending);
    }
    LogInfo.log("save_", "pre query push time is " + (historyTime == 0 ? Long.valueOf(historyTime) : StringUtils.timeStringAll(historyTime)) + " , interval = " + interval + " , so after " + (interval / 60) + " minutes,at " + StringUtils.timeStringAll(((long) (interval * 1000)) + historyTime) + " will start query service again");
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:22,代码来源:LetvPushService.java

示例7: setAlarm

import android.app.AlarmManager; //导入方法依赖的package包/类
public static void setAlarm(Context context, Intent intent, int notificationId, Calendar calendar) {
    intent.putExtra("NOTIFICATION_ID", notificationId);
    AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
    PendingIntent pendingIntent = PendingIntent.getBroadcast(context, notificationId, intent, PendingIntent.FLAG_UPDATE_CURRENT);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        alarmManager.setExactAndAllowWhileIdle(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), pendingIntent);
    } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        alarmManager.setExact(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), pendingIntent);
    } else {
        alarmManager.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), pendingIntent);
    }
}
 
开发者ID:adithya321,项目名称:SOS-The-Healthcare-Companion,代码行数:14,代码来源:AlarmUtil.java

示例8: setExactAlarm

import android.app.AlarmManager; //导入方法依赖的package包/类
/**
 * Wrapper to set alarm at exact time
 * @see AlarmManager#setExact(int, long, PendingIntent)
 */
@TargetApi(Build.VERSION_CODES.KITKAT)
public static void setExactAlarm(AlarmManager alarmManager, int alarmType, long firstTime,
        PendingIntent pendingIntent) {
    if(isCompatible(Build.VERSION_CODES.KITKAT)) {
        alarmManager.setExact(alarmType, firstTime, pendingIntent);
    }else {
        alarmManager.set(alarmType, firstTime, pendingIntent);
    }
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:14,代码来源:Compatibility.java

示例9: setAlarm

import android.app.AlarmManager; //导入方法依赖的package包/类
private void setAlarm(long milliseconds) {

        AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
        Intent intent = new Intent(context, AlarmReceiver.class);
        intent.putExtra(ONE_TIME, Boolean.FALSE);
        PendingIntent pi = PendingIntent.getBroadcast(context, 0, intent, 0);

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            am.setExact(AlarmManager.RTC_WAKEUP, milliseconds, pi);
        } else {
            am.set(AlarmManager.RTC_WAKEUP, milliseconds, pi);
        }
    }
 
开发者ID:imjaspreet,项目名称:Camera-Background-Servce,代码行数:14,代码来源:AlarmHelper.java

示例10: configureAlarmManager

import android.app.AlarmManager; //导入方法依赖的package包/类
/**
 * 装在定时任务
 * @param Time
 */
private void configureAlarmManager(long Time) {
    AlarmManager manager = (AlarmManager) mContext.getSystemService(ALARM_SERVICE);
    PendingIntent pendIntent = getPendingIntent();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        manager.setExactAndAllowWhileIdle(AlarmManager.RTC_WAKEUP, Time, pendIntent);
    } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        manager.setExact(AlarmManager.RTC_WAKEUP, Time, pendIntent);
    } else {
        manager.set(AlarmManager.RTC_WAKEUP, Time, pendIntent);
    }
}
 
开发者ID:BolexLiu,项目名称:TimeTask,代码行数:16,代码来源:TimeTask.java

示例11: setAlarmTime

import android.app.AlarmManager; //导入方法依赖的package包/类
/**
 * 设置下次触发时间
 * @param ms 距离下次的毫秒数
 */
private void setAlarmTime(long ms){
    AlarmManager manager = (AlarmManager) getSystemService(ALARM_SERVICE);
    Intent tmpIntent = new Intent(this, CalendarReceiver.class);
    tmpIntent.setAction(AppConstants.MAIN_CALENDAR_SERVICE);
    PendingIntent pi = PendingIntent.getBroadcast(this, 0, tmpIntent, PendingIntent.FLAG_UPDATE_CURRENT);
    if (Helper.isKitKatOrLater()) {
        manager.setExact(AlarmManager.RTC_WAKEUP, ms, pi);
    } else {
        manager.set(AlarmManager.RTC_WAKEUP, ms, pi);
    }
}
 
开发者ID:mainh,项目名称:MainCalendar,代码行数:16,代码来源:CalendarService.java

示例12: destroyIt

import android.app.AlarmManager; //导入方法依赖的package包/类
private void destroyIt() {
    if (!isConfigChanged) {
        getThisApplication().getTracker().send(
                new HitBuilders.EventBuilder().setCategory("App lifecycle")
                        .setAction("Finished the app manually").build());
        ArduinoConnectivityPopup.isOpened = false;
        stopService();
        stopLooperThread();
        moveTaskToBack(true);
        OneSheeldSdk.getManager().disconnectAll();
        // // unExpeted
        if (!isBackPressed) {
            Enumeration<String> enumKey = ((OneSheeldApplication)
                    getApplication()).getRunningShields().keys();
            while (enumKey.hasMoreElements()) {
                String key = enumKey.nextElement();
                ((OneSheeldApplication) getApplication())
                        .getRunningShields().get(key).resetThis();
                ((OneSheeldApplication) getApplication())
                        .getRunningShields().remove(key);
            }
            Intent in = new Intent(getIntent());
            PendingIntent intent = PendingIntent.getActivity(
                    getBaseContext(), 0, in, getIntent().getFlags());
            AlarmManager mgr = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
                mgr.setExact(AlarmManager.RTC, System.currentTimeMillis() + 100,
                        intent);
            } else {
                mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 100,
                        intent);
            }
            killAllProcesses();
        } else
            killAllProcesses();
    }
    isConfigChanged = false;
    isBackPressed = false;
}
 
开发者ID:Dnet3,项目名称:CustomAndroidOneSheeld,代码行数:40,代码来源:MainActivity.java

示例13: setAlarmExact

import android.app.AlarmManager; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.KITKAT)
public static void setAlarmExact(Context context, int type, long triggerAtMillis,
                                 PendingIntent pendingIntent) {
    AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        alarmManager.setExact(type, triggerAtMillis, pendingIntent);
    } else {
        alarmManager.set(type, triggerAtMillis, pendingIntent);
    }
}
 
开发者ID:HanyeeWang,项目名称:GeekZone,代码行数:11,代码来源:AppUtils.java

示例14: startAlarmClock

import android.app.AlarmManager; //导入方法依赖的package包/类
@TargetApi(19)
public static void startAlarmClock(Context context, AlarmModel alarm) {
    Intent intent = new Intent(context, BootAlarmActivity.class);
    intent.putExtra(ALARM_CLOCK, alarm);
    PendingIntent pi = PendingIntent.getActivity(context, alarm.id, intent, PendingIntent.FLAG_CANCEL_CURRENT);
    AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);

    long nextTime = calculateNextTime(alarm.hour,
            alarm.minute, getWeeks(alarm));
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        alarmManager.setExact(AlarmManager.RTC_WAKEUP, nextTime, pi);
    } else {
        alarmManager.set(AlarmManager.RTC_WAKEUP, nextTime, pi);
    }
}
 
开发者ID:segasunset,项目名称:WeatherAlarmClock,代码行数:16,代码来源:AlarmManagerHelper.java

示例15: scheduleAlarm

import android.app.AlarmManager; //导入方法依赖的package包/类
public static void scheduleAlarm(AlarmManager alarmManager, int type, long triggerAtMillis, PendingIntent operation) {
	alarmManager.setExact(type, triggerAtMillis, operation);
}
 
开发者ID:treasure-lau,项目名称:Linphone4Android,代码行数:4,代码来源:ApiNineteenPlus.java


注:本文中的android.app.AlarmManager.setExact方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。