Example usage for android.app PendingIntent FLAG_ONE_SHOT

List of usage examples for android.app PendingIntent FLAG_ONE_SHOT

Introduction

In this page you can find the example usage for android.app PendingIntent FLAG_ONE_SHOT.

Prototype

int FLAG_ONE_SHOT

To view the source code for android.app PendingIntent FLAG_ONE_SHOT.

Click Source Link

Document

Flag indicating that this PendingIntent can be used only once.

Usage

From source file:com.yahala.android.NotificationsController.java

private void showOrUpdateNotification(boolean notifyAboutLast) {
    if (!UserConfig.isClientActivated() || pushMessages.isEmpty()) {
        dismissNotification();/*w w w  . j  a v  a 2 s  .c o  m*/
        return;
    }
    try {
        XMPPManager.getInstance().maybeStartReconnect();

        MessageObject lastMessageObject = pushMessages.get(0);

        String dialog_id = lastMessageObject.getDialogId();
        // String chat_id = lastMessageObject.messageOwner.to_id.chat_id;
        String user_jid = lastMessageObject.messageOwner.getJid();
        /*if (user_jid == 0) {
        user_jid = lastMessageObject.messageOwner.from_id;
        } else if (usjer_id == UserConfig.getClientUserId()) {
        user_jid = lastMessageObject.messageOwner.from_id;
        }*/

        TLRPC.User user = ContactsController.getInstance().friendsDict.get(user_jid);
        TLRPC.Chat chat = null;
        /*if (chat_id != 0) {
        chat = MessagesController.getInstance().chats.get(chat_id);
        }*/
        TLRPC.FileLocation photoPath = null;

        boolean notifyDisabled = false;
        boolean needVibrate = false;
        String choosenSoundPath = null;
        int ledColor = 0xff00ff00;
        boolean inAppSounds = false;
        boolean inAppVibrate = false;
        boolean inAppPreview = false;
        int vibrate_override = 0;

        SharedPreferences preferences = ApplicationLoader.applicationContext
                .getSharedPreferences("Notifications", Context.MODE_PRIVATE);
        int notify_override = preferences.getInt("notify2_" + dialog_id, 0);
        /*  if (!notifyAboutLast || notify_override == 2 || (!preferences.getBoolean("EnableAll", true) || chat_id != 0 && !preferences.getBoolean("EnableGroup", true)) && notify_override == 0) {
        notifyDisabled = true;
          }*/

        String defaultPath = Settings.System.DEFAULT_NOTIFICATION_URI.getPath();
        if (!notifyDisabled) {
            inAppSounds = preferences.getBoolean("EnableInAppSounds", true);
            inAppVibrate = preferences.getBoolean("EnableInAppVibrate", true);
            inAppPreview = preferences.getBoolean("EnableInAppPreview", true);
            vibrate_override = preferences.getInt("vibrate_" + dialog_id, 0);

            choosenSoundPath = preferences.getString("sound_path_" + dialog_id, null);
            /* if (chat_id != 0) {
            if (choosenSoundPath != null && choosenSoundPath.equals(defaultPath)) {
                choosenSoundPath = null;
            } else if (choosenSoundPath == null) {
                choosenSoundPath = preferences.getString("GroupSoundPath", defaultPath);
            }
            needVibrate = preferences.getBoolean("EnableVibrateGroup", true);
            ledColor = preferences.getInt("GroupLed", 0xff00ff00);
             } else*/
            if (user_jid.equals("0")) {
                if (choosenSoundPath != null && choosenSoundPath.equals(defaultPath)) {
                    choosenSoundPath = null;
                } else if (choosenSoundPath == null) {
                    choosenSoundPath = preferences.getString("GlobalSoundPath", defaultPath);
                }
                needVibrate = preferences.getBoolean("EnableVibrateAll", true);
                ledColor = preferences.getInt("MessagesLed", 0xff00ff00);
            }
            if (preferences.contains("color_" + dialog_id)) {
                ledColor = preferences.getInt("color_" + dialog_id, 0);
            }

            if (!needVibrate && vibrate_override == 1) {
                needVibrate = true;
            } else if (needVibrate && vibrate_override == 2) {
                needVibrate = false;
            }
            if (!ApplicationLoader.mainInterfacePaused) {
                if (!inAppSounds) {
                    choosenSoundPath = null;
                }
                if (!inAppVibrate) {
                    needVibrate = false;
                }
            }
        }

        Intent intent = new Intent(ApplicationLoader.applicationContext, LaunchActivity.class);
        intent.setAction("com.tmessages.openchat" + Math.random() + Integer.MAX_VALUE);
        intent.setFlags(32768);
        if (dialog_id != "0") {
            // if (chat_id != 0) {
            //     intent.putExtra("chatId", chat_id);
            // } else if (user_id != 0) {
            intent.putExtra("user_jid", user_jid);
            //  }
            if (pushDialogs.size() == 1) {
                if (chat != null) {
                    if (chat.photo != null && chat.photo.photo_small != null
                            && chat.photo.photo_small.volume_id != 0 && chat.photo.photo_small.local_id != 0) {
                        photoPath = chat.photo.photo_small;
                    }
                } else {
                    if (user.photo != null && user.photo.photo_small != null
                            && user.photo.photo_small.volume_id != 0 && user.photo.photo_small.local_id != 0) {
                        photoPath = user.photo.photo_small;
                    }
                }
            }
        }
        PendingIntent contentIntent = PendingIntent.getActivity(ApplicationLoader.applicationContext, 0, intent,
                PendingIntent.FLAG_ONE_SHOT);

        String name = null;
        boolean replace = true;
        if (dialog_id == "0" || pushDialogs.size() > 1) {
            name = LocaleController.getString("AppName", R.string.AppName);
            replace = false;
        } else {
            if (chat != null) {
                name = chat.title;
            } else {
                name = Utilities.formatName(user.first_name, user.last_name);
            }
        }

        String detailText = null;
        if (pushDialogs.size() == 1) {
            detailText = LocaleController.formatPluralString("NewMessages", total_unread_count);
        } else {
            detailText = String.format("%s %s",
                    LocaleController.formatPluralString("NewMessages", total_unread_count),
                    LocaleController.formatPluralString("FromContacts", pushDialogs.size()));
        }

        NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(
                ApplicationLoader.applicationContext).setContentTitle(name)
                        .setSmallIcon(R.drawable.notification).setAutoCancel(true).setContentText(detailText)
                        .setContentIntent(contentIntent);

        String lastMessage = null;
        if (pushMessages.size() == 1) {
            String message = lastMessage = getStringForMessage(pushMessages.get(0));
            if (message == null) {
                return;
            }
            if (replace) {
                if (chat != null) {
                    message = message.replace(" @ " + name, "");
                } else {
                    message = message.replace(name + ": ", "").replace(name + " ", "");
                }
            }
            mBuilder.setStyle(new NotificationCompat.BigTextStyle().bigText(message));
        } else {
            NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
            inboxStyle.setBigContentTitle(name);
            int count = Math.min(10, pushMessages.size());
            for (int i = 0; i < count; i++) {
                String message = getStringForMessage(pushMessages.get(i));
                if (message == null) {
                    continue;
                }
                if (i == 0) {
                    lastMessage = message;
                }
                if (pushDialogs.size() == 1) {
                    if (replace) {
                        if (chat != null) {
                            message = message.replace(" @ " + name, "");
                        } else {
                            message = message.replace(name + ": ", "").replace(name + " ", "");
                        }
                    }
                }
                inboxStyle.addLine(message);
            }
            inboxStyle.setSummaryText(detailText);
            mBuilder.setStyle(inboxStyle);
        }

        if (photoPath != null) {
            Bitmap img = FileLoader.getInstance().getImageFromMemory(photoPath, null, null, "50_50", false);
            if (img != null) {
                mBuilder.setLargeIcon(img);
            }
        }

        if (!notifyDisabled) {
            if (ApplicationLoader.mainInterfacePaused || inAppPreview) {
                mBuilder.setTicker(lastMessage);
            }
            if (choosenSoundPath != null && !choosenSoundPath.equals("NoSound")) {
                if (choosenSoundPath.equals(defaultPath)) {
                    mBuilder.setSound(Settings.System.DEFAULT_NOTIFICATION_URI,
                            AudioManager.STREAM_NOTIFICATION);
                } else {
                    mBuilder.setSound(Uri.parse(choosenSoundPath), AudioManager.STREAM_NOTIFICATION);
                }
            }
            if (ledColor != 0) {
                mBuilder.setLights(ledColor, 1000, 1000);
            }
            if (needVibrate) {
                mBuilder.setVibrate(new long[] { 0, 100, 0, 100 });
            }
        } else {
            mBuilder.setVibrate(new long[] { 0, 0 });
        }

        notificationManager.notify(1, mBuilder.build());
        if (preferences.getBoolean("EnablePebbleNotifications", false)) {
            sendAlertToPebble(lastMessage);
        }
    } catch (Exception e) {
        FileLog.e("tmessages", e);
    }
}

From source file:com.etime.ETimeActivity.java

/**
 * Set the alarm that will perform autoclock out at the specified time.
 * @param alarmTime time in milliseconds since epoch when the alarm
 *                  should run./*from ww w  . j a  v  a  2  s  . c  om*/
 */
public void setOneTimeAlarm(long alarmTime) {
    Intent intent = new Intent(this, TimeAlarm.class);
    intent.putExtra("username", loginName);
    intent.putExtra("password", password);
    pendingIntentAutoClockAlarm = PendingIntent.getBroadcast(this, 0, intent, PendingIntent.FLAG_ONE_SHOT);
    am.set(AlarmManager.RTC_WAKEUP, alarmTime, pendingIntentAutoClockAlarm);
}

From source file:com.compal.telephonytest.TelephonyTest.java

public void prepareSMS() {

    IntentFilter sendIntentFilter = new IntentFilter(SMS_SEND_ACTION);
    IntentFilter deliveryIntentFilter = new IntentFilter(SMS_DELIVERY_ACTION);
    IntentFilter dataSmsReceivedIntentFilter = new IntentFilter(DATA_SMS_RECEIVED_ACTION);

    mSendIntent = new Intent(SMS_SEND_ACTION);
    mDeliveryIntent = new Intent(SMS_DELIVERY_ACTION);

    dataSmsReceivedIntentFilter.addDataScheme("sms");
    dataSmsReceivedIntentFilter.addDataAuthority("localhost", port.toString());

    context.registerReceiver(SmsBroadcastReceiver, sendIntentFilter);
    context.registerReceiver(SmsBroadcastReceiver, deliveryIntentFilter);
    context.registerReceiver(SmsBroadcastReceiver, dataSmsReceivedIntentFilter);

    mText = mText + "_" + Long.toString(System.currentTimeMillis());

    PendingIntent mSentIntent = PendingIntent.getBroadcast(getInstrumentation().getTargetContext(), 0,
            mSendIntent, PendingIntent.FLAG_ONE_SHOT);
    PendingIntent mDeliveredIntent = PendingIntent.getBroadcast(getInstrumentation().getTargetContext(), 0,
            mDeliveryIntent, PendingIntent.FLAG_ONE_SHOT);

    byte[] data = mText.getBytes();
    mSmsManager.sendDataMessage(mPhoneNumber, null, port, data, mSentIntent, mDeliveredIntent);

}

From source file:com.amazonaws.mobileconnectors.pinpoint.targeting.notification.NotificationClient.java

private PendingIntent createOpenAppPendingIntent(final Bundle pushBundle, final Class<?> targetClass,
        final String campaignId, final int requestId, final String intentAction) {
    PendingIntent contentIntent = null;//from  w  w  w .j  a v  a 2 s  . co m
    if (intentAction.equals(GCM_INTENT_ACTION)) {
        contentIntent = PendingIntent.getService(pinpointContext.getApplicationContext(), requestId,
                this.notificationIntent(pushBundle, campaignId, requestId, GCM_INTENT_ACTION, targetClass),
                PendingIntent.FLAG_ONE_SHOT);
    } else {
        contentIntent = PendingIntent.getBroadcast(pinpointContext.getApplicationContext(), requestId,
                this.notificationIntent(pushBundle, campaignId, requestId, FCM_INTENT_ACTION, targetClass),
                PendingIntent.FLAG_ONE_SHOT);
        PinpointNotificationReceiver.setNotificationClient(this);
    }
    return contentIntent;

}

From source file:com.android.providers.downloads.DownloadService.java

/**
 * Update {@link #mDownloads} to match {@link DownloadProvider} state.
 * Depending on current download state it may enqueue {@link DownloadThread}
 * instances, request {@link DownloadScanner} scans, update user-visible
 * notifications, and/or schedule future actions with {@link AlarmManager}.
 * <p>/* w  ww.  j a  v  a2  s. c o m*/
 * Should only be called from {@link #mUpdateThread} as after being
 * requested through {@link #enqueueUpdate()}.
 *
 * @return If there are active tasks being processed, as of the database
 *         snapshot taken in this update.
 */
private boolean updateLocked() {
    final long now = mSystemFacade.currentTimeMillis();
    boolean isActive = false;
    long nextActionMillis = Long.MAX_VALUE;

    final Set<Long> staleIds = Sets.newHashSet(mDownloads.keySet());
    final ContentResolver resolver = getContentResolver();
    Cursor cursor = null;
    try {
        cursor = resolver.query(Downloads.Impl.ALL_DOWNLOADS_CONTENT_URI, null, null, null, null);
        final DownloadInfo.Reader reader = new DownloadInfo.Reader(resolver, cursor);
        final int idColumn = cursor.getColumnIndexOrThrow(Downloads.Impl._ID);
        while (cursor.moveToNext()) {
            final long id = cursor.getLong(idColumn);
            long currentDownloadNextActionMillis = Long.MAX_VALUE;

            DownloadInfo info = mDownloads.get(id);
            if (info != null) {
                updateDownload(reader, info, now);
            } else {
                // Check xunlei engine status when create a new task
                info = insertDownloadLocked(reader, now);
            }

            if (info.mDeleted) {
                // Delete download if requested, but only after cleaning up
                if (!TextUtils.isEmpty(info.mMediaProviderUri)) {
                    resolver.delete(Uri.parse(info.mMediaProviderUri), null, null);
                }

                // if download has been completed, delete xxx, else delete xxx.midownload
                if (info.mStatus == Downloads.Impl.STATUS_SUCCESS) {
                    if (info.mFileName != null) {
                        deleteFileIfExists(info.mFileName);
                    }
                } else {
                    if (info.mFileName != null) {
                        deleteFileIfExists(info.mFileName + Helpers.sDownloadingExtension);
                    }
                }
                resolver.delete(info.getAllDownloadsUri(), null, null);
            } else {
                staleIds.remove(id);
                // Kick off download task if ready
                String pkg = TextUtils.isEmpty(info.mPackage) ? sUnknownPackage : info.mPackage;
                final boolean activeDownload = info.startDownloadIfReady(MyExecutor.getExecutorInstance(pkg));

                // Kick off media scan if completed
                final boolean activeScan = info.startScanIfReady(mScanner);

                // get current download task's next action millis
                currentDownloadNextActionMillis = info.nextActionMillis(now);

                XLConfig.LOGD("Download " + info.mId + ": activeDownload=" + activeDownload + ", activeScan="
                        + activeScan);

                isActive |= activeDownload;
                isActive |= activeScan;
                // if equals 0, keep download service on.
                isActive |= (currentDownloadNextActionMillis == 0);
            }

            // Keep track of nearest next action
            nextActionMillis = Math.min(currentDownloadNextActionMillis, nextActionMillis);
        }
    } catch (SQLiteDiskIOException e) {
        XLConfig.LOGD("error when updateLocked: ", e);
    } catch (Exception e) {
        XLConfig.LOGD("error when updateLocked: ", e);
    } finally {
        if (cursor != null) {
            cursor.close();
        }
    }

    // Clean up stale downloads that disappeared
    for (Long id : staleIds) {
        deleteDownloadLocked(id);
    }

    // Update notifications visible to user
    mNotifier.updateWith(mDownloads.values());

    // Set alarm when next action is in future. It's okay if the service
    // continues to run in meantime, since it will kick off an update pass.
    if (nextActionMillis > 0 && nextActionMillis < Long.MAX_VALUE) {
        XLConfig.LOGD("scheduling start in " + nextActionMillis + "ms");

        final Intent intent = new Intent(Constants.ACTION_RETRY);
        intent.setClass(this, DownloadReceiver.class);
        mAlarmManager.set(AlarmManager.RTC_WAKEUP, now + nextActionMillis,
                PendingIntent.getBroadcast(this, 0, intent, PendingIntent.FLAG_ONE_SHOT));
    }

    return isActive;
}

From source file:com.prod.intelligent7.engineautostart.ConnectDaemonService.java

void startRecurringBootAlarm() {
    if (recurringBootIntent != null) {
        alarmManager.cancel(recurringBootIntent);
        //return;
    }//from w  w w.  j a v a  2  s  . c o m
    recurringBootIntent = null;
    GregorianCalendar gToday = new GregorianCalendar(
            TimeZone.getTimeZone(getResources().getString(R.string.my_time_zone_en)));
    if (gToday.get(Calendar.HOUR_OF_DAY) >= 7 && gToday.get(Calendar.HOUR_OF_DAY) < 19)
        return;
    String bootParameter = readBootParameter(99);
    Log.i("ALARM_SET", "got n boot parameters " + (bootParameter == null ? "nothing" : bootParameter));
    if (bootParameter == null)
        return;
    int idx = bootParameter.indexOf("-");
    if (idx < 0)
        return;
    long init_wait = Long.parseLong(bootParameter.substring(0, idx));
    if (init_wait < 2000) //init_wait=2000;
    {
        int ixx = bootParameter.indexOf("-", idx + 1);
        long on_time = Long.parseLong(bootParameter.substring(idx + 1, ixx));
        sendCommand("M5-" + new DecimalFormat("00").format(on_time / 60000));

        long off_time = Long.parseLong(bootParameter.substring(ixx + 1));
        setRecurringBootAlarm(on_time, off_time);
        return;
    }
    Intent jIntent = new Intent(this, ConnectDaemonService.class);
    //M1-00 (cool) or M1-01 (warm)
    jIntent.setAction(ALARM_NBOOT);
    jIntent.putExtra(ConnectDaemonService.ALARM_DONE, ALARM_NBOOT);
    jIntent.putExtra(ConnectDaemonService.ALARM_NBOOT, bootParameter.substring(idx + 1));
    recurringBootIntent = PendingIntent.getService(this, ++nBootAlarmRequestId % 100 + 200, jIntent,
            PendingIntent.FLAG_ONE_SHOT);
    alarmManager.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + init_wait, recurringBootIntent);
    //alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + init_wait,
    //on_time + off_time, recurringBootIntent);
    //Log.i("ALARM_SET", "to start recurring boot in " + init_wait/60000);//+" with interval "+(on_time+off_time)/60000);
    Log.i("ALARM_SET", "to start recurring boot in " + init_wait / 60000);
    //startScheduledJobs();
}

From source file:com.cerema.cloud2.files.services.FileDownloader.java

/**
 * Updates the status notification with the result of a download operation.
 *
 * @param downloadResult Result of the download operation.
 * @param download       Finished download operation
 *///from  w w w  .  j  a  va2  s.c  o  m
private void notifyDownloadResult(DownloadFileOperation download, RemoteOperationResult downloadResult) {
    mNotificationManager.cancel(R.string.downloader_download_in_progress_ticker);
    if (!downloadResult.isCancelled()) {
        int tickerId = (downloadResult.isSuccess()) ? R.string.downloader_download_succeeded_ticker
                : R.string.downloader_download_failed_ticker;

        boolean needsToUpdateCredentials = (downloadResult.getCode() == ResultCode.UNAUTHORIZED
                || downloadResult.isIdPRedirection());
        tickerId = (needsToUpdateCredentials) ? R.string.downloader_download_failed_credentials_error
                : tickerId;

        mNotificationBuilder.setTicker(getString(tickerId)).setContentTitle(getString(tickerId))
                .setAutoCancel(true).setOngoing(false).setProgress(0, 0, false);

        if (needsToUpdateCredentials) {

            // let the user update credentials with one click
            Intent updateAccountCredentials = new Intent(this, AuthenticatorActivity.class);
            updateAccountCredentials.putExtra(AuthenticatorActivity.EXTRA_ACCOUNT, download.getAccount());
            updateAccountCredentials.putExtra(AuthenticatorActivity.EXTRA_ACTION,
                    AuthenticatorActivity.ACTION_UPDATE_EXPIRED_TOKEN);
            updateAccountCredentials.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            updateAccountCredentials.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
            updateAccountCredentials.addFlags(Intent.FLAG_FROM_BACKGROUND);
            mNotificationBuilder.setContentIntent(PendingIntent.getActivity(this,
                    (int) System.currentTimeMillis(), updateAccountCredentials, PendingIntent.FLAG_ONE_SHOT));

        } else {
            // TODO put something smart in showDetailsIntent
            Intent showDetailsIntent = new Intent();
            mNotificationBuilder.setContentIntent(
                    PendingIntent.getActivity(this, (int) System.currentTimeMillis(), showDetailsIntent, 0));
        }

        mNotificationBuilder.setContentText(
                ErrorMessageAdapter.getErrorCauseMessage(downloadResult, download, getResources()));
        mNotificationManager.notify(tickerId, mNotificationBuilder.build());

        // Remove success notification
        if (downloadResult.isSuccess()) {
            // Sleep 2 seconds, so show the notification before remove it
            NotificationDelayer.cancelWithDelay(mNotificationManager,
                    R.string.downloader_download_succeeded_ticker, 2000);
        }

    }
}

From source file:io.github.hidroh.materialistic.AppUtils.java

@NonNull
private static Intent createViewIntent(Context context, WebItem item, String url, CustomTabsSession session) {
    if (Preferences.customChromeTabEnabled(context)) {
        return new CustomTabsIntent.Builder(session)
                .setToolbarColor(//  w  w  w. j  a  v a  2s  . c o  m
                        ContextCompat.getColor(context, AppUtils.getThemedResId(context, R.attr.colorPrimary)))
                .setShowTitle(true).enableUrlBarHiding().addDefaultShareMenuItem()
                .addMenuItem(context.getString(R.string.comments), PendingIntent.getActivity(context, 0,
                        new Intent(context, ItemActivity.class).putExtra(ItemActivity.EXTRA_ITEM, item)
                                .putExtra(ItemActivity.EXTRA_OPEN_COMMENTS, true),
                        PendingIntent.FLAG_ONE_SHOT))
                .build().intent.setData(Uri.parse(url));
    } else {
        return new Intent(Intent.ACTION_VIEW, Uri.parse(url));
    }
}

From source file:com.androidinspain.deskclock.data.TimerModel.java

/**
 * Updates the callback given to this application from the {@link AlarmManager} that signals the
 * expiration of the next timer. If no timers are currently set to expire (i.e. no running
 * timers exist) then this method clears the expiration callback from AlarmManager.
 *///  w w  w.ja  v  a2s  .  co  m
private void updateAlarmManager() {
    // Locate the next firing timer if one exists.
    Timer nextExpiringTimer = null;
    for (Timer timer : getMutableTimers()) {
        if (timer.isRunning()) {
            if (nextExpiringTimer == null) {
                nextExpiringTimer = timer;
            } else if (timer.getExpirationTime() < nextExpiringTimer.getExpirationTime()) {
                nextExpiringTimer = timer;
            }
        }
    }

    // Build the intent that signals the timer expiration.
    final Intent intent = TimerService.createTimerExpiredIntent(mContext, nextExpiringTimer);

    if (nextExpiringTimer == null) {
        // Cancel the existing timer expiration callback.
        final PendingIntent pi = PendingIntent.getService(mContext, 0, intent,
                PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_NO_CREATE);
        if (pi != null) {
            mAlarmManager.cancel(pi);
            pi.cancel();
        }
    } else {
        // Update the existing timer expiration callback.
        final PendingIntent pi = PendingIntent.getService(mContext, 0, intent,
                PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_UPDATE_CURRENT);
        schedulePendingIntent(mAlarmManager, nextExpiringTimer.getExpirationTime(), pi);
    }
}

From source file:com.prod.intelligent7.engineautostart.ConnectDaemonService.java

void setRecurringBootAlarm(long on_time, long idle_interval) {
    if (recurringBootIntent != null) {
        alarmManager.cancel(recurringBootIntent);
        //return;
    }/*  ww  w . j  a  v a  2  s.  co  m*/
    recurringBootIntent = null;
    GregorianCalendar gToday = new GregorianCalendar(
            TimeZone.getTimeZone(getResources().getString(R.string.my_time_zone_en)));
    if (gToday.get(Calendar.HOUR_OF_DAY) >= 7 && gToday.get(Calendar.HOUR_OF_DAY) < 21)
        return;
    long total_wait = idle_interval;//on_time+idle_interval;
    String bootParameter = "" + on_time + "-" + idle_interval;
    Intent jIntent = new Intent(this, ConnectDaemonService.class);
    //M1-00 (cool) or M1-01 (warm)
    jIntent.setAction(ALARM_NBOOT);
    jIntent.putExtra(ConnectDaemonService.ALARM_DONE, ALARM_NBOOT);
    jIntent.putExtra(ConnectDaemonService.ALARM_NBOOT, bootParameter);
    recurringBootIntent = PendingIntent.getService(this, ++nBootAlarmRequestId % 100 + 300, jIntent,
            PendingIntent.FLAG_ONE_SHOT);
    alarmManager.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + total_wait, recurringBootIntent);
    Log.i("ALARM_SET", "to start recurring boot in " + total_wait / 60000);
    //startScheduledJobs();
}