Example usage for android.app PendingIntent FLAG_CANCEL_CURRENT

List of usage examples for android.app PendingIntent FLAG_CANCEL_CURRENT

Introduction

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

Prototype

int FLAG_CANCEL_CURRENT

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

Click Source Link

Document

Flag indicating that if the described PendingIntent already exists, the current one should be canceled before generating a new one.

Usage

From source file:org.messic.android.smartphone.notifications.MessicPlayerNotification.java

private void createNotification() {
    if (this.notification != null) {
        return;/* w ww  .j  ava2 s.c o  m*/
    }

    mNotificationManager = (NotificationManager) this.service.getSystemService(Context.NOTIFICATION_SERVICE);
    RemoteViews smallContentView = new RemoteViews(this.service.getPackageName(), R.layout.notification_small);
    RemoteViews bigContentView = new RemoteViews(this.service.getPackageName(), R.layout.notification_big);

    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this.service);
    mBuilder.setSmallIcon(R.mipmap.ic_launcher);
    mBuilder.setContentTitle("title");
    mBuilder.setPriority(Notification.PRIORITY_MAX);
    mBuilder.setContent(bigContentView);

    Notification n = mBuilder.build();

    n.contentView = smallContentView;
    n.bigContentView = bigContentView;

    Intent intentClose = new Intent(ACTION_CLOSE);
    PendingIntent pintentClose = PendingIntent.getBroadcast(this.service, 0, intentClose, 0);
    bigContentView.setOnClickPendingIntent(R.id.bignotification_ivclose, pintentClose);
    smallContentView.setOnClickPendingIntent(R.id.bignotification_ivclose, pintentClose);

    Intent intentBack = new Intent(ACTION_BACK);
    PendingIntent pintentBack = PendingIntent.getBroadcast(this.service, 0, intentBack, 0);
    bigContentView.setOnClickPendingIntent(R.id.bignotification_ivback, pintentBack);
    smallContentView.setOnClickPendingIntent(R.id.bignotification_ivback, pintentBack);

    Intent intentPlay = new Intent(ACTION_PLAY);
    PendingIntent pintentPlay = PendingIntent.getBroadcast(this.service, 0, intentPlay, 0);
    bigContentView.setOnClickPendingIntent(R.id.bignotification_ivplay, pintentPlay);
    smallContentView.setOnClickPendingIntent(R.id.bignotification_ivplay, pintentPlay);

    Intent intentPause = new Intent(ACTION_PAUSE);
    PendingIntent pintentPause = PendingIntent.getBroadcast(this.service, 0, intentPause, 0);
    bigContentView.setOnClickPendingIntent(R.id.bignotification_ivpause, pintentPause);
    smallContentView.setOnClickPendingIntent(R.id.bignotification_ivpause, pintentPause);

    Intent intentNext = new Intent(ACTION_NEXT);
    PendingIntent pintentNext = PendingIntent.getBroadcast(this.service, 0, intentNext, 0);
    bigContentView.setOnClickPendingIntent(R.id.bignotification_ivnext, pintentNext);
    smallContentView.setOnClickPendingIntent(R.id.bignotification_ivnext, pintentNext);

    Intent intentAlbum = new Intent(ACTION_ALBUM);
    PendingIntent pintentAlbum = PendingIntent.getBroadcast(this.service, 0, intentAlbum,
            PendingIntent.FLAG_CANCEL_CURRENT);
    bigContentView.setOnClickPendingIntent(R.id.bignotification_ivcurrent_cover, pintentAlbum);
    bigContentView.setOnClickPendingIntent(R.id.bignotification_tvcurrent_author, pintentAlbum);
    bigContentView.setOnClickPendingIntent(R.id.bignotification_tvcurrent_song, pintentAlbum);
    smallContentView.setOnClickPendingIntent(R.id.bignotification_ivcurrent_cover, pintentAlbum);
    smallContentView.setOnClickPendingIntent(R.id.bignotification_tvcurrent_author, pintentAlbum);
    smallContentView.setOnClickPendingIntent(R.id.bignotification_tvcurrent_song, pintentAlbum);

    this.notification = n;
    this.service.startForeground(ONGOING_NOTIFICATION_ID, notification);
    this.registerBroadcastActions();
}

From source file:com.ubergeek42.WeechatAndroid.service.RelayService.java

private void showNotification(String tickerText, String content) {
    PendingIntent contentIntent = PendingIntent.getActivity(this, 0, new Intent(this, WeechatActivity.class),
            PendingIntent.FLAG_CANCEL_CURRENT);

    NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
    builder.setContentIntent(contentIntent).setSmallIcon(R.drawable.ic_notification)
            .setContentTitle(getString(R.string.app_version)).setContentText(content).setTicker(tickerText)
            .setWhen(System.currentTimeMillis());

    Notification notification = builder.getNotification();
    notification.flags |= Notification.FLAG_ONGOING_EVENT | Notification.FLAG_NO_CLEAR;
    notificationManger.notify(NOTIFICATION_ID, notification);
}

From source file:com.mobiperf.MeasurementScheduler.java

/**
 * Create notification that indicates the service is running.
 *//*from w  ww .j av a 2 s  .  co  m*/
private Notification createServiceRunningNotification() {
    // The intent to launch when the user clicks the expanded notification
    Intent intent = new Intent(this, SpeedometerApp.class);
    PendingIntent pendIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);

    // This constructor is deprecated in 3.x. But most phones still run 2.x systems
    Notification notice = new Notification(R.drawable.icon_statusbar,
            getString(R.string.notificationSchedulerStarted), System.currentTimeMillis());
    notice.flags |= Notification.FLAG_NO_CLEAR | Notification.FLAG_ONGOING_EVENT;

    // This is deprecated in 3.x. But most phones still run 2.x systems
    notice.setLatestEventInfo(this, getString(R.string.app_name),
            getString(R.string.notificationServiceRunning), pendIntent);
    return notice;
}

From source file:com.jjcamera.apps.iosched.service.SessionAlarmService.java

private void scheduleAlarm(final long sessionStart, final long sessionEnd, final long alarmOffset) {

    NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    nm.cancel(NOTIFICATION_ID);/*from   ww  w  . ja  v  a 2 s .com*/
    final long currentTime = UIUtils.getCurrentTime(this);
    // If the session is already started, do not schedule system notification.
    if (currentTime > sessionStart) {
        LOGD(TAG, "Not scheduling alarm because target time is in the past: " + sessionStart);
        return;
    }

    // By default, sets alarm to go off at 10 minutes before session start time.  If alarm
    // offset is provided, alarm is set to go off by that much time from now.
    long alarmTime;
    if (alarmOffset == UNDEFINED_ALARM_OFFSET) {
        alarmTime = sessionStart - MILLI_TEN_MINUTES;
    } else {
        alarmTime = currentTime + alarmOffset;
    }

    LOGD(TAG, "Scheduling alarm for " + alarmTime + " = " + (new Date(alarmTime)).toString());

    final Intent notifIntent = new Intent(ACTION_NOTIFY_SESSION, null, this, SessionAlarmService.class);
    // Setting data to ensure intent's uniqueness for different session start times.
    notifIntent.setData(new Uri.Builder().authority("com.jjcamera.apps.iosched")
            .path(String.valueOf(sessionStart)).build());
    notifIntent.putExtra(SessionAlarmService.EXTRA_SESSION_START, sessionStart);
    LOGD(TAG, "-> Intent extra: session start " + sessionStart);
    notifIntent.putExtra(SessionAlarmService.EXTRA_SESSION_END, sessionEnd);
    LOGD(TAG, "-> Intent extra: session end " + sessionEnd);
    notifIntent.putExtra(SessionAlarmService.EXTRA_SESSION_ALARM_OFFSET, alarmOffset);
    LOGD(TAG, "-> Intent extra: session alarm offset " + alarmOffset);
    PendingIntent pi = PendingIntent.getService(this, 0, notifIntent, PendingIntent.FLAG_CANCEL_CURRENT);
    final AlarmManager am = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
    // Schedule an alarm to be fired to notify user of added sessions are about to begin.
    LOGD(TAG, "-> Scheduling RTC_WAKEUP alarm at " + alarmTime);
    am.set(AlarmManager.RTC_WAKEUP, alarmTime, pi);
}

From source file:com.meetingcpp.sched.service.SessionAlarmService.java

private void scheduleAlarm(final long sessionStart, final long sessionEnd, final long alarmOffset) {

    NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    nm.cancel(NOTIFICATION_ID);//  ww w .  j av a2s .  c  o  m
    final long currentTime = UIUtils.getCurrentTime(this);
    // If the session is already started, do not schedule system notification.
    if (currentTime > sessionStart) {
        LOGD(TAG, "Not scheduling alarm because target time is in the past: " + sessionStart);
        return;
    }

    // By default, sets alarm to go off at 10 minutes before session start time.  If alarm
    // offset is provided, alarm is set to go off by that much time from now.
    long alarmTime;
    if (alarmOffset == UNDEFINED_ALARM_OFFSET) {
        alarmTime = sessionStart - MILLI_TEN_MINUTES;
    } else {
        alarmTime = currentTime + alarmOffset;
    }

    LOGD(TAG, "Scheduling alarm for " + alarmTime + " = " + (new Date(alarmTime)).toString());

    final Intent notifIntent = new Intent(ACTION_NOTIFY_SESSION, null, this, SessionAlarmService.class);
    // Setting data to ensure intent's uniqueness for different session start times.
    notifIntent.setData(
            new Uri.Builder().authority("com.meetingcpp.sched").path(String.valueOf(sessionStart)).build());
    notifIntent.putExtra(SessionAlarmService.EXTRA_SESSION_START, sessionStart);
    LOGD(TAG, "-> Intent extra: session start " + sessionStart);
    notifIntent.putExtra(SessionAlarmService.EXTRA_SESSION_END, sessionEnd);
    LOGD(TAG, "-> Intent extra: session end " + sessionEnd);
    notifIntent.putExtra(SessionAlarmService.EXTRA_SESSION_ALARM_OFFSET, alarmOffset);
    LOGD(TAG, "-> Intent extra: session alarm offset " + alarmOffset);
    PendingIntent pi = PendingIntent.getService(this, 0, notifIntent, PendingIntent.FLAG_CANCEL_CURRENT);
    final AlarmManager am = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
    // Schedule an alarm to be fired to notify user of added sessions are about to begin.
    LOGD(TAG, "-> Scheduling RTC_WAKEUP alarm at " + alarmTime);
    am.set(AlarmManager.RTC_WAKEUP, alarmTime, pi);
}

From source file:com.atlas.mars.weatherradar.MainActivity.java

void morningAlarm() {

    //todo  ?   ??
    //startService(new Intent(this, MorningService.class));

    long time = db.getMorningWakeUp();
    alarmManagerMorning = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
    morningIntent = createIntent("morningAction", "extraMorning", MorningBroadCast.class);
    startService(morningIntent);//from   ww w .  ja  v  a 2 s  .c  o m
    pIntent2 = PendingIntent.getBroadcast(this, 0, morningIntent, PendingIntent.FLAG_CANCEL_CURRENT);
    alarmManagerMorning.cancel(pIntent2);

    alarmManagerMorning.set(AlarmManager.RTC_WAKEUP, time, pIntent2);
    //todo ?   ?  ??
    // alarmManagerMorning.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis()+1*1000, pIntent2);
}

From source file:com.adithya321.sharesanalysis.activities.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    sharedPreferences = getSharedPreferences("prefs", 0);
    if (sharedPreferences.getBoolean("first", true)) {
        startActivity(new Intent(this, IntroActivity.class));
        return;/*  w  w  w.  j  a v  a2  s.c  o  m*/
    }

    setContentView(R.layout.activity_main);

    toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    AccountHeader accountHeader = new AccountHeaderBuilder().withHeaderBackground(R.drawable.header)
            .withCompactStyle(true).withActivity(this)
            .addProfiles(new ProfileDrawerItem().withName(sharedPreferences.getString("name", "Name"))
                    .withEmail("Target : " + sharedPreferences.getFloat("target", 20) + "%")
                    .withIcon(getResources().getDrawable(R.mipmap.ic_launcher)))
            .withOnAccountHeaderListener(new AccountHeader.OnAccountHeaderListener() {
                @Override
                public boolean onProfileChanged(View view, IProfile profile, boolean currentProfile) {
                    return false;
                }
            }).build();

    final DatabaseHandler databaseHandler = new DatabaseHandler(getApplicationContext());

    drawer = new DrawerBuilder().withActivity(this).withToolbar(toolbar).withAccountHeader(accountHeader)
            .withActionBarDrawerToggleAnimated(true)
            .addDrawerItems(
                    new PrimaryDrawerItem().withIdentifier(0).withName("Dashboard")
                            .withIcon(R.drawable.ic_timeline_gray),
                    new PrimaryDrawerItem().withIdentifier(1).withName("Fund Flow")
                            .withIcon(R.drawable.ic_compare_arrows_gray),
                    new DividerDrawerItem(),
                    new PrimaryDrawerItem().withIdentifier(2).withName("Share Purchase")
                            .withIcon(R.drawable.ic_add_red)
                            .withTextColor(getResources().getColor(R.color.red_500)),
                    new PrimaryDrawerItem().withIdentifier(3).withName("Share Sales")
                            .withIcon(R.drawable.ic_remove_green)
                            .withTextColor(getResources().getColor(R.color.colorPrimary)),
                    new PrimaryDrawerItem().withIdentifier(4).withName("Share Holdings")
                            .withIcon(R.drawable.ic_account_balance_blue)
                            .withTextColor(getResources().getColor(R.color.colorAccent)),
                    new DividerDrawerItem(),
                    new PrimaryDrawerItem().withIdentifier(5).withName("Charts")
                            .withIcon(R.drawable.ic_insert_chart_gray),
                    new PrimaryDrawerItem()
                            .withIdentifier(6).withName("Summary").withIcon(R.drawable.ic_description_gray),
                    new DividerDrawerItem(),
                    new PrimaryDrawerItem().withIdentifier(7).withName("Feedback")
                            .withIcon(R.drawable.ic_feedback_gray),
                    new PrimaryDrawerItem()
                            .withIdentifier(8).withName("Help").withIcon(R.drawable.ic_help_gray),
                    new DividerDrawerItem(),
                    new PrimaryDrawerItem().withIdentifier(10).withName("Backup")
                            .withIcon(R.drawable.ic_backup_gray),
                    new PrimaryDrawerItem()
                            .withIdentifier(11).withName("Restore").withIcon(R.drawable.ic_restore_gray),
                    new DividerDrawerItem(),
                    new PrimaryDrawerItem().withIdentifier(21).withName("Settings")
                            .withIcon(R.drawable.ic_settings_gray),
                    new PrimaryDrawerItem().withIdentifier(22).withName("About")
                            .withIcon(R.drawable.ic_info_gray))
            .withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
                @Override
                public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
                    boolean flag;
                    List<Share> shareList = databaseHandler.getShares();
                    if (drawerItem != null) {
                        flag = true;
                        switch ((int) drawerItem.getIdentifier()) {
                        case 0:
                            if (shareList.size() < 1)
                                drawer.setSelection(2, true);
                            else
                                switchFragment("Dashboard", "Dashboard");
                            break;
                        case 1:
                            switchFragment("Fund Flow", "FundFlow");
                            break;

                        case 2:
                            switchFragment("Share Purchase", "SharePurchaseMain");
                            break;
                        case 3:
                            if (shareList.size() < 1)
                                drawer.setSelection(2, true);
                            else
                                switchFragment("Share Sales", "SharePurchaseMain");
                            break;
                        case 4:
                            if (shareList.size() < 1)
                                drawer.setSelection(2, true);
                            else
                                switchFragment("Share Holdings", "ShareHoldings");
                            break;

                        case 5:
                            if (shareList.size() < 1)
                                drawer.setSelection(2, true);
                            else
                                switchFragment("Charts", "Charts");
                            break;
                        case 6:
                            if (shareList.size() < 1)
                                drawer.setSelection(2, true);
                            else
                                switchFragment("Summary", "Summary");
                            break;

                        case 7:
                            ConversationActivity.show(MainActivity.this);
                            break;
                        case 8:
                            startActivity(new Intent(MainActivity.this, IntroActivity.class));
                            break;

                        case 10:
                            RealmBackupRestore backup = new RealmBackupRestore(MainActivity.this);
                            backup.backup();
                            break;
                        case 11:
                            RealmBackupRestore restore = new RealmBackupRestore(MainActivity.this);
                            restore.restore();
                            Intent mStartActivity = new Intent(MainActivity.this, MainActivity.class);
                            int mPendingIntentId = 123456;
                            PendingIntent mPendingIntent = PendingIntent.getActivity(MainActivity.this,
                                    mPendingIntentId, mStartActivity, PendingIntent.FLAG_CANCEL_CURRENT);
                            AlarmManager mgr = (AlarmManager) MainActivity.this
                                    .getSystemService(Context.ALARM_SERVICE);
                            mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 100, mPendingIntent);
                            System.exit(0);
                            break;

                        case 21:
                            startActivity(new Intent(MainActivity.this, ProfileActivity.class));
                            break;
                        case 22:
                            new LibsBuilder().withActivityStyle(Libs.ActivityStyle.LIGHT_DARK_TOOLBAR)
                                    .withActivityTitle(getString(R.string.app_name)).withAboutIconShown(true)
                                    .withAboutVersionShown(true).withVersionShown(true).withLicenseShown(true)
                                    .withLicenseDialog(true).withListener(libsListener)
                                    .start(MainActivity.this);
                            break;

                        default:
                            switchFragment("Dashboard", "Dashboard");
                            break;
                        }
                    } else {
                        flag = false;
                    }
                    return flag;
                }
            }).build();

    if (savedInstanceState == null)
        drawer.setSelection(0, true);
    else
        drawer.setSelection(savedInstanceState.getLong("drawerSelection"), true);

    CustomActivityOnCrash.install(this);
}

From source file:im.neon.activity.CommonActivityUtils.java

/**
 * Restart the application after 100ms/*w  w w. j a  v a2  s  . com*/
 *
 * @param activity activity
 */
public static void restartApp(Activity activity) {
    // clear the preferences
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
    SharedPreferences.Editor editor = preferences.edit();

    // use the preference to avoid infinite relaunch on some devices
    // the culprit activity is restarted when System.exit is called.
    // so called it once to fix it
    if (!preferences.getBoolean(RESTART_IN_PROGRESS_KEY, false)) {
        CommonActivityUtils.displayToast(activity.getApplicationContext(),
                "Restart the application (low memory)");

        Log.e(LOG_TAG, "Kill the application");
        editor.putBoolean(RESTART_IN_PROGRESS_KEY, true);
        editor.commit();

        PendingIntent mPendingIntent = PendingIntent.getActivity(activity, 314159,
                new Intent(activity, LoginActivity.class), PendingIntent.FLAG_CANCEL_CURRENT);

        // so restart the application after 100ms
        AlarmManager mgr = (AlarmManager) activity.getSystemService(Context.ALARM_SERVICE);
        mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 50, mPendingIntent);

        System.exit(0);
    } else {
        Log.e(LOG_TAG, "The application is restarting, please wait !!");
        activity.finish();
    }
}

From source file:com.ncode.android.apps.schedo.service.SessionAlarmService.java

private void scheduleAlarm(final long sessionStart, final long sessionEnd, final long alarmOffset) {

    NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    nm.cancel(NOTIFICATION_ID);/*  ww w .  j  a va  2 s  .  c  o m*/
    final long currentTime = UIUtils.getCurrentTime(this);
    // If the session is already started, do not schedule system notification.
    if (currentTime > sessionStart) {
        LOGD(TAG, "Not scheduling alarm because target time is in the past: " + sessionStart);
        return;
    }

    // By default, sets alarm to go off at 10 minutes before session start time.  If alarm
    // offset is provided, alarm is set to go off by that much time from now.
    long alarmTime;
    if (alarmOffset == UNDEFINED_ALARM_OFFSET) {
        alarmTime = sessionStart - MILLI_TEN_MINUTES;
    } else {
        alarmTime = currentTime + alarmOffset;
    }

    LOGD(TAG, "Scheduling alarm for " + alarmTime + " = " + (new Date(alarmTime)).toString());

    final Intent notifIntent = new Intent(ACTION_NOTIFY_SESSION, null, this, SessionAlarmService.class);
    // Setting data to ensure intent's uniqueness for different session start times.
    notifIntent.setData(new Uri.Builder().authority("com.ncode.android.apps.schedo")
            .path(String.valueOf(sessionStart)).build());
    notifIntent.putExtra(SessionAlarmService.EXTRA_SESSION_START, sessionStart);
    LOGD(TAG, "-> Intent extra: session start " + sessionStart);
    notifIntent.putExtra(SessionAlarmService.EXTRA_SESSION_END, sessionEnd);
    LOGD(TAG, "-> Intent extra: session end " + sessionEnd);
    notifIntent.putExtra(SessionAlarmService.EXTRA_SESSION_ALARM_OFFSET, alarmOffset);
    LOGD(TAG, "-> Intent extra: session alarm offset " + alarmOffset);
    PendingIntent pi = PendingIntent.getService(this, 0, notifIntent, PendingIntent.FLAG_CANCEL_CURRENT);
    final AlarmManager am = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
    // Schedule an alarm to be fired to notify user of added sessions are about to begin.
    LOGD(TAG, "-> Scheduling RTC_WAKEUP alarm at " + alarmTime);
    am.set(AlarmManager.RTC_WAKEUP, alarmTime, pi);
}

From source file:com.google.samples.apps.sergio.service.SessionAlarmService.java

private void scheduleAlarm(final long sessionStart, final long sessionEnd, final long alarmOffset) {

    NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    nm.cancel(NOTIFICATION_ID);//from w w  w. j a v a 2s. c  o  m
    final long currentTime = UIUtils.getCurrentTime(this);
    // If the session is already started, do not schedule system notification.
    if (currentTime > sessionStart) {
        LOGD(TAG, "Not scheduling alarm because target time is in the past: " + sessionStart);
        return;
    }

    // By default, sets alarm to go off at 10 minutes before session start time.  If alarm
    // offset is provided, alarm is set to go off by that much time from now.
    long alarmTime;
    if (alarmOffset == UNDEFINED_ALARM_OFFSET) {
        alarmTime = sessionStart - MILLI_TEN_MINUTES;
    } else {
        alarmTime = currentTime + alarmOffset;
    }

    LOGD(TAG, "Scheduling alarm for " + alarmTime + " = " + (new Date(alarmTime)).toString());

    final Intent notifIntent = new Intent(ACTION_NOTIFY_SESSION, null, this, SessionAlarmService.class);
    // Setting data to ensure intent's uniqueness for different session start times.
    notifIntent.setData(new Uri.Builder().authority("com.google.samples.apps.sergio")
            .path(String.valueOf(sessionStart)).build());
    notifIntent.putExtra(SessionAlarmService.EXTRA_SESSION_START, sessionStart);
    LOGD(TAG, "-> Intent extra: session start " + sessionStart);
    notifIntent.putExtra(SessionAlarmService.EXTRA_SESSION_END, sessionEnd);
    LOGD(TAG, "-> Intent extra: session end " + sessionEnd);
    notifIntent.putExtra(SessionAlarmService.EXTRA_SESSION_ALARM_OFFSET, alarmOffset);
    LOGD(TAG, "-> Intent extra: session alarm offset " + alarmOffset);
    PendingIntent pi = PendingIntent.getService(this, 0, notifIntent, PendingIntent.FLAG_CANCEL_CURRENT);
    final AlarmManager am = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
    // Schedule an alarm to be fired to notify user of added sessions are about to begin.
    LOGD(TAG, "-> Scheduling RTC_WAKEUP alarm at " + alarmTime);
    am.set(AlarmManager.RTC_WAKEUP, alarmTime, pi);
}