Example usage for android.app PendingIntent getService

List of usage examples for android.app PendingIntent getService

Introduction

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

Prototype

public static PendingIntent getService(Context context, int requestCode, @NonNull Intent intent,
        @Flags int flags) 

Source Link

Document

Retrieve a PendingIntent that will start a service, like calling Context#startService Context.startService() .

Usage

From source file:edu.mit.media.funf.configured.ConfiguredPipeline.java

private void scheduleAlarm(String action, long delayInSeconds) {
    Intent i = new Intent(this, getClass());
    i.setAction(action);//from  w ww.j a v  a2 s  .com
    boolean noAlarmExists = (PendingIntent.getService(this, 0, i, PendingIntent.FLAG_NO_CREATE) == null);
    if (noAlarmExists) {
        PendingIntent pi = PendingIntent.getService(this, 0, i, PendingIntent.FLAG_UPDATE_CURRENT);
        AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
        long delayInMilliseconds = Utils.secondsToMillis(delayInSeconds);
        long startTimeInMilliseconds = System.currentTimeMillis() + delayInMilliseconds;
        Log.i(TAG, "Scheduling alarm for '" + action + "' at " + Utils.millisToSeconds(startTimeInMilliseconds)
                + " and every " + delayInSeconds + " seconds");
        // Inexact repeating doesn't work unlesss interval is 15, 30 min, or 1, 6, or 24 hours
        alarmManager.setInexactRepeating(AlarmManager.RTC_WAKEUP, startTimeInMilliseconds, delayInMilliseconds,
                pi);
    }
}

From source file:com.near.chimerarevo.activities.MainActivity.java

@Override
public void onDestroy() {
    super.onDestroy();
    if (ImageLoader.getInstance().isInited()) {
        ImageLoader.getInstance().clearDiskCache();
        ImageLoader.getInstance().clearMemoryCache();
    }/*from www  . j ava  2s.  c o m*/
    if (mHelper != null)
        mHelper.dispose();

    if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean("news_search_pref", true)) {
        Intent intent = new Intent(getApplicationContext(), NewsService.class);
        PendingIntent pintent = PendingIntent.getService(getApplicationContext(), 0, intent, 0);
        AlarmManager alarm = (AlarmManager) getSystemService(Context.ALARM_SERVICE);

        alarm.cancel(pintent);

        long delay;
        int sel = Integer.parseInt(
                PreferenceManager.getDefaultSharedPreferences(this).getString("notification_delay_pref", "0"));

        switch (sel) {
        case 0:
            delay = AlarmManager.INTERVAL_FIFTEEN_MINUTES;
            break;
        case 1:
            delay = AlarmManager.INTERVAL_HALF_HOUR;
            break;
        case 2:
            delay = AlarmManager.INTERVAL_HOUR;
            break;
        case 3:
            delay = 2 * AlarmManager.INTERVAL_HOUR;
            break;
        case 4:
            delay = 3 * AlarmManager.INTERVAL_HOUR;
            break;
        case 5:
            delay = 6 * AlarmManager.INTERVAL_HOUR;
            break;
        case 6:
            delay = AlarmManager.INTERVAL_HALF_DAY;
            break;
        case 7:
            delay = AlarmManager.INTERVAL_DAY;
            break;
        default:
            delay = AlarmManager.INTERVAL_HOUR;
            break;
        }

        alarm.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.uptimeMillis(), delay, pintent);
    }
}

From source file:com.morlunk.leeroy.LeeroyUpdateService.java

private void handleCheckUpdates(Intent intent, boolean notify, ResultReceiver receiver) {
    List<LeeroyApp> appList = LeeroyApp.getApps(getPackageManager());

    if (appList.size() == 0) {
        return;/*from w  ww . j av  a  2 s . com*/
    }

    List<LeeroyAppUpdate> updates = new LinkedList<>();
    List<LeeroyApp> notUpdatedApps = new LinkedList<>();
    List<LeeroyException> exceptions = new LinkedList<>();
    for (LeeroyApp app : appList) {
        try {
            String paramUrl = app.getJenkinsUrl() + "/api/json?tree=lastSuccessfulBuild[number,url]";
            URL url = new URL(paramUrl);
            URLConnection conn = url.openConnection();
            Reader reader = new InputStreamReader(conn.getInputStream());

            JsonReader jsonReader = new JsonReader(reader);
            jsonReader.beginObject();
            jsonReader.nextName();
            jsonReader.beginObject();

            int latestSuccessfulBuild = 0;
            String buildUrl = null;
            while (jsonReader.hasNext()) {
                String name = jsonReader.nextName();
                if ("number".equals(name)) {
                    latestSuccessfulBuild = jsonReader.nextInt();
                } else if ("url".equals(name)) {
                    buildUrl = jsonReader.nextString();
                } else {
                    throw new RuntimeException("Unknown key " + name);
                }
            }
            jsonReader.endObject();
            jsonReader.endObject();
            jsonReader.close();

            if (latestSuccessfulBuild > app.getJenkinsBuild()) {
                LeeroyAppUpdate update = new LeeroyAppUpdate();
                update.app = app;
                update.newBuild = latestSuccessfulBuild;
                update.newBuildUrl = buildUrl;
                updates.add(update);
            } else {
                notUpdatedApps.add(app);
            }
        } catch (MalformedURLException e) {
            e.printStackTrace();
            CharSequence appName = app.getApplicationInfo().loadLabel(getPackageManager());
            exceptions.add(new LeeroyException(app, getString(R.string.invalid_url, appName), e));
        } catch (IOException e) {
            e.printStackTrace();
            exceptions.add(new LeeroyException(app, e));
        }
    }

    if (notify) {
        NotificationManagerCompat nm = NotificationManagerCompat.from(this);
        if (updates.size() > 0) {
            NotificationCompat.Builder ncb = new NotificationCompat.Builder(this);
            ncb.setSmallIcon(R.drawable.ic_stat_update);
            ncb.setTicker(getString(R.string.updates_available));
            ncb.setContentTitle(getString(R.string.updates_available));
            ncb.setContentText(getString(R.string.num_updates, updates.size()));
            ncb.setPriority(NotificationCompat.PRIORITY_LOW);
            ncb.setVisibility(NotificationCompat.VISIBILITY_PUBLIC);
            Intent appIntent = new Intent(this, AppListActivity.class);
            appIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
            ncb.setContentIntent(
                    PendingIntent.getActivity(this, 0, appIntent, PendingIntent.FLAG_CANCEL_CURRENT));
            ncb.setAutoCancel(true);
            NotificationCompat.InboxStyle style = new NotificationCompat.InboxStyle();
            for (LeeroyAppUpdate update : updates) {
                CharSequence appName = update.app.getApplicationInfo().loadLabel(getPackageManager());
                style.addLine(getString(R.string.notify_app_update, appName, update.app.getJenkinsBuild(),
                        update.newBuild));
            }
            style.setSummaryText(getString(R.string.app_name));
            ncb.setStyle(style);
            ncb.setNumber(updates.size());
            nm.notify(NOTIFICATION_UPDATE, ncb.build());
        }

        if (exceptions.size() > 0) {
            NotificationCompat.Builder ncb = new NotificationCompat.Builder(this);
            ncb.setSmallIcon(R.drawable.ic_stat_error);
            ncb.setTicker(getString(R.string.error_checking_updates));
            ncb.setContentTitle(getString(R.string.error_checking_updates));
            ncb.setContentText(getString(R.string.click_to_retry));
            ncb.setPriority(NotificationCompat.PRIORITY_LOW);
            ncb.setVisibility(NotificationCompat.VISIBILITY_PUBLIC);
            ncb.setContentIntent(PendingIntent.getService(this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT));
            ncb.setAutoCancel(true);
            ncb.setNumber(exceptions.size());
            nm.notify(NOTIFICATION_ERROR, ncb.build());
        }
    }

    if (receiver != null) {
        Bundle results = new Bundle();
        results.putParcelableArrayList(EXTRA_UPDATE_LIST, new ArrayList<>(updates));
        results.putParcelableArrayList(EXTRA_NO_UPDATE_LIST, new ArrayList<>(notUpdatedApps));
        results.putParcelableArrayList(EXTRA_EXCEPTION_LIST, new ArrayList<>(exceptions));
        receiver.send(0, results);
    }
}

From source file:com.jmstudios.redmoon.presenter.ScreenFilterPresenter.java

private void refreshForegroundNotification() {
    if (isOff()) {
        return;//from  ww w. ja v a  2 s . c o  m
    }
    Context context = mView.getContext();

    ProfilesModel profilesModel = new ProfilesModel(context);

    String title = context.getString(R.string.app_name);
    int color = context.getResources().getColor(R.color.color_primary);
    Intent offCommand = mFilterCommandFactory.createCommand(ScreenFilterService.COMMAND_OFF);

    int smallIconResId = R.drawable.notification_icon_half_moon;
    String contentText;
    int pauseOrResumeDrawableResId;
    Intent pauseOrResumeCommand;
    String pauseOrResumeActionText;

    if (isPaused()) {
        Log.d(TAG, "Creating notification while in pause state");
        contentText = context.getString(R.string.paused);
        pauseOrResumeDrawableResId = R.drawable.ic_play;
        pauseOrResumeCommand = mFilterCommandFactory.createCommand(ScreenFilterService.COMMAND_ON);
        pauseOrResumeActionText = context.getString(R.string.resume_action);
    } else {
        Log.d(TAG, "Creating notification while NOT in pause state");
        contentText = context.getString(R.string.running);
        pauseOrResumeDrawableResId = R.drawable.ic_pause;
        pauseOrResumeCommand = mFilterCommandFactory.createCommand(ScreenFilterService.COMMAND_PAUSE);
        pauseOrResumeActionText = context.getString(R.string.pause_action);
    }

    Intent shadesActivityIntent = new Intent(context, ShadesActivity.class);
    shadesActivityIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);

    PendingIntent pauseOrResumePI = PendingIntent.getService(context, REQUEST_CODE_ACTION_PAUSE_OR_RESUME,
            pauseOrResumeCommand, PendingIntent.FLAG_UPDATE_CURRENT);

    PendingIntent settingsPI = PendingIntent.getActivity(context, REQUEST_CODE_ACTION_SETTINGS,
            shadesActivityIntent, PendingIntent.FLAG_UPDATE_CURRENT);

    Intent nextProfileIntent = new Intent(context, NextProfileCommandReceiver.class);

    PendingIntent nextProfilePI = PendingIntent.getBroadcast(context, REQUEST_CODE_NEXT_PROFILE,
            nextProfileIntent, 0);

    mNotificationBuilder = new NotificationCompat.Builder(mContext);
    mNotificationBuilder.setSmallIcon(smallIconResId).setContentTitle(title).setContentText(contentText)
            .setColor(color).setContentIntent(settingsPI)
            .addAction(pauseOrResumeDrawableResId, pauseOrResumeActionText, pauseOrResumePI)
            .addAction(R.drawable.ic_next_profile,
                    ProfilesHelper.getProfileName(profilesModel, mSettingsModel.getProfile(), context),
                    nextProfilePI)
            .setPriority(Notification.PRIORITY_MIN);

    if (isPaused()) {
        Log.d(TAG, "Creating a dismissible notification");
        NotificationManager mNotificationManager = (NotificationManager) mContext
                .getSystemService(Context.NOTIFICATION_SERVICE);
        mNotificationManager.notify(NOTIFICATION_ID, mNotificationBuilder.build());
    } else {
        Log.d(TAG, "Creating a persistent notification");
        mServiceController.startForeground(NOTIFICATION_ID, mNotificationBuilder.build());
    }
}

From source file:com.hippo.ehviewer.download.DownloadService.java

@SuppressWarnings("deprecation")
private void ensureDownloadingBuilder() {
    if (mDownloadingBuilder != null) {
        return;//from   w w w .j ava  2s.c o m
    }

    Intent stopAllIntent = new Intent(this, DownloadService.class);
    stopAllIntent.setAction(ACTION_STOP_ALL);
    PendingIntent piStopAll = PendingIntent.getService(this, 0, stopAllIntent, 0);

    mDownloadingBuilder = new NotificationCompat.Builder(getApplicationContext())
            .setSmallIcon(android.R.drawable.stat_sys_download).setOngoing(true).setAutoCancel(false)
            .setCategory(NotificationCompat.CATEGORY_PROGRESS)
            .setColor(getResources().getColor(R.color.colorPrimary))
            .addAction(R.drawable.ic_pause_x24, getString(R.string.stat_download_action_stop_all), piStopAll)
            .setShowWhen(false);

    mDownloadingDelay = new NotificationDelay(this, mNotifyManager, mDownloadingBuilder, ID_DOWNLOADING);
}

From source file:alaindc.crowdroid.SensorsIntentService.java

public void stub_onSensorChanged(int typeSensor) {
    if (typeSensor < 0)
        return;//  w ww.  j a v  a  2 s . c  o  m

    float value, minf, maxf;
    switch (typeSensor) {
    case Sensor.TYPE_AMBIENT_TEMPERATURE:
        minf = -20;
        maxf = 42;
        break;
    case Sensor.TYPE_PRESSURE: // https://it.wikipedia.org/wiki/Pressione_atmosferica
        minf = 870;
        maxf = 1085;
        break;
    case Sensor.TYPE_RELATIVE_HUMIDITY:
        minf = 30;
        maxf = 100;
        break;
    default:
        minf = 0;
        maxf = 0;
        break;
    }

    value = random.nextFloat() * (maxf - minf) + minf;

    int index = Constants.getIndexAlarmForSensor(typeSensor);

    SharedPreferences sharedPref = getApplicationContext().getSharedPreferences(Constants.PREF_FILE,
            Context.MODE_PRIVATE);
    SharedPreferences.Editor editor = sharedPref.edit();
    editor.putString(Constants.PREF_SENSOR_ + typeSensor, Float.toString(value));
    editor.commit();

    // Update view
    Intent senseintent = new Intent(Constants.INTENT_UPDATE_SENSORS);
    senseintent.putExtra(Constants.INTENT_RECEIVED_DATA_EXTRA_DATA,
            "Sensor " + Constants.getNameOfSensor(typeSensor) + " value: " + Float.toString(value));
    LocalBroadcastManager.getInstance(this).sendBroadcast(senseintent);

    // Set the alarm random
    alarmMgr = (AlarmManager) getApplicationContext().getSystemService(Context.ALARM_SERVICE);
    Intent intentAlarm = new Intent(getApplicationContext(), SensorsIntentService.class);
    intentAlarm.setAction(Constants.INTENT_STUB_SENSOR_CHANGED + typeSensor);
    intentAlarm.putExtra(Constants.INTENT_STUB_SENSOR_CHANGED_TYPE, typeSensor);
    alarmIntent = PendingIntent.getService(getApplicationContext(), 0, intentAlarm, 0);

    // TODO Set timeout time from server indications
    int seconds = random.nextInt(50) + 10; // 10/60 sec
    alarmMgr.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + seconds * 1000,
            alarmIntent);
}

From source file:com.spire.activity_recognition.DetectionRequester.java

/**
 * Get a PendingIntent to send with the request to get activity recognition updates. Location
 * Services issues the Intent inside this PendingIntent whenever a activity recognition update
 * occurs.// w w w  .j  av a2 s.  c  om
 *
 * @return A PendingIntent for the IntentService that handles activity recognition updates.
 */
private PendingIntent createRequestPendingIntent() {

    // If the PendingIntent already exists
    if (getRequestPendingIntent() != null) {

        // Return the existing intent
        Debug.log(TAG, "createRequestPendingIntent: Returning an existing one");
        return mActivityRecognitionPendingIntent;

        // If no PendingIntent exists
    } else {
        Debug.log(TAG, "createRequestPendingIntent: Creating a new pointer.");

        // Create an Intent pointing to the IntentService
        Intent intent = new Intent(mContext, ActivityRecognitionIntentService.class);

        /*
         * Return a PendingIntent to start the IntentService.
         * Always create a PendingIntent sent to Location Services
         * with FLAG_UPDATE_CURRENT, so that sending the PendingIntent
         * again updates the original. Otherwise, Location Services
         * can't match the PendingIntent to requests made with it.
         */
        mActivityRecognitionPendingIntent = PendingIntent.getService(mContext, 0, intent,
                PendingIntent.FLAG_UPDATE_CURRENT);

        setRequestPendingIntent(mActivityRecognitionPendingIntent);
        return mActivityRecognitionPendingIntent;

    }

}

From source file:com.wizardsofm.deskclock.data.TimerNotificationBuilderPreN.java

@Override
public Notification build(Context context, NotificationModel nm, List<Timer> unexpired) {
    final Timer timer = unexpired.get(0);
    final long remainingTime = timer.getRemainingTime();

    // Generate some descriptive text, a title, and some actions based on timer states.
    final String contentText;
    final String contentTitle;
    @DrawableRes/*w ww.  java  2 s .com*/
    int firstActionIconId, secondActionIconId = 0;
    @StringRes
    int firstActionTitleId, secondActionTitleId = 0;
    Intent firstActionIntent, secondActionIntent = null;

    if (unexpired.size() == 1) {
        contentText = formatElapsedTimeUntilExpiry(context, remainingTime);

        if (timer.isRunning()) {
            // Single timer is running.
            if (TextUtils.isEmpty(timer.getLabel())) {
                contentTitle = context.getString(com.wizardsofm.deskclock.R.string.timer_notification_label);
            } else {
                contentTitle = timer.getLabel();
            }

            firstActionIconId = com.wizardsofm.deskclock.R.drawable.ic_pause_24dp;
            firstActionTitleId = com.wizardsofm.deskclock.R.string.timer_pause;
            firstActionIntent = new Intent(context, TimerService.class)
                    .setAction(HandleDeskClockApiCalls.ACTION_PAUSE_TIMER)
                    .putExtra(HandleDeskClockApiCalls.EXTRA_TIMER_ID, timer.getId());

            secondActionIconId = com.wizardsofm.deskclock.R.drawable.ic_add_24dp;
            secondActionTitleId = com.wizardsofm.deskclock.R.string.timer_plus_1_min;
            secondActionIntent = new Intent(context, TimerService.class)
                    .setAction(HandleDeskClockApiCalls.ACTION_ADD_MINUTE_TIMER)
                    .putExtra(HandleDeskClockApiCalls.EXTRA_TIMER_ID, timer.getId());
        } else {
            // Single timer is paused.
            contentTitle = context.getString(com.wizardsofm.deskclock.R.string.timer_paused);

            firstActionIconId = com.wizardsofm.deskclock.R.drawable.ic_start_24dp;
            firstActionTitleId = com.wizardsofm.deskclock.R.string.sw_resume_button;
            firstActionIntent = new Intent(context, TimerService.class)
                    .setAction(HandleDeskClockApiCalls.ACTION_START_TIMER)
                    .putExtra(HandleDeskClockApiCalls.EXTRA_TIMER_ID, timer.getId());

            secondActionIconId = com.wizardsofm.deskclock.R.drawable.ic_reset_24dp;
            secondActionTitleId = com.wizardsofm.deskclock.R.string.sw_reset_button;
            secondActionIntent = new Intent(context, TimerService.class)
                    .setAction(HandleDeskClockApiCalls.ACTION_RESET_TIMER)
                    .putExtra(HandleDeskClockApiCalls.EXTRA_TIMER_ID, timer.getId());
        }
    } else {
        if (timer.isRunning()) {
            // At least one timer is running.
            final String timeRemaining = formatElapsedTimeUntilExpiry(context, remainingTime);
            contentText = context.getString(com.wizardsofm.deskclock.R.string.next_timer_notif, timeRemaining);
            contentTitle = context.getString(com.wizardsofm.deskclock.R.string.timers_in_use, unexpired.size());
        } else {
            // All timers are paused.
            contentText = context.getString(com.wizardsofm.deskclock.R.string.all_timers_stopped_notif);
            contentTitle = context.getString(com.wizardsofm.deskclock.R.string.timers_stopped,
                    unexpired.size());
        }

        firstActionIconId = com.wizardsofm.deskclock.R.drawable.ic_reset_24dp;
        firstActionTitleId = com.wizardsofm.deskclock.R.string.timer_reset_all;
        firstActionIntent = TimerService.createResetUnexpiredTimersIntent(context);
    }

    // Intent to load the app and show the timer when the notification is tapped.
    final Intent showApp = new Intent(context, HandleDeskClockApiCalls.class)
            .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK).setAction(HandleDeskClockApiCalls.ACTION_SHOW_TIMERS)
            .putExtra(HandleDeskClockApiCalls.EXTRA_TIMER_ID, timer.getId())
            .putExtra(HandleDeskClockApiCalls.EXTRA_EVENT_LABEL,
                    com.wizardsofm.deskclock.R.string.label_notification);

    final PendingIntent pendingShowApp = PendingIntent.getActivity(context, 0, showApp,
            PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_UPDATE_CURRENT);

    final NotificationCompat.Builder builder = new NotificationCompat.Builder(context).setOngoing(true)
            .setLocalOnly(true).setShowWhen(false).setAutoCancel(false).setContentText(contentText)
            .setContentTitle(contentTitle).setContentIntent(pendingShowApp)
            .setSmallIcon(com.wizardsofm.deskclock.R.drawable.stat_notify_timer)
            .setPriority(NotificationCompat.PRIORITY_HIGH).setCategory(NotificationCompat.CATEGORY_ALARM)
            .setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
            .setColor(ContextCompat.getColor(context, com.wizardsofm.deskclock.R.color.default_background));

    final PendingIntent action1 = Utils.pendingServiceIntent(context, firstActionIntent);
    final String action1Title = context.getString(firstActionTitleId);
    builder.addAction(firstActionIconId, action1Title, action1);

    if (secondActionIntent != null) {
        final PendingIntent action2 = Utils.pendingServiceIntent(context, secondActionIntent);
        final String action2Title = context.getString(secondActionTitleId);
        builder.addAction(secondActionIconId, action2Title, action2);
    }

    final AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
    final Intent updateNotification = TimerService.createUpdateNotificationIntent(context);
    if (timer.isRunning() && remainingTime > MINUTE_IN_MILLIS) {
        // Schedule a callback to update the time-sensitive information of the running timer.
        final PendingIntent pi = PendingIntent.getService(context, 0, updateNotification,
                PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_UPDATE_CURRENT);

        final long nextMinuteChange = remainingTime % MINUTE_IN_MILLIS;
        final long triggerTime = SystemClock.elapsedRealtime() + nextMinuteChange;
        TimerModel.schedulePendingIntent(am, triggerTime, pi);
    } else {
        // Cancel the update notification callback.
        final PendingIntent pi = PendingIntent.getService(context, 0, updateNotification,
                PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_NO_CREATE);
        if (pi != null) {
            am.cancel(pi);
            pi.cancel();
        }
    }

    return builder.build();
}

From source file:com.njlabs.amrita.aid.news.NewsUpdateService.java

@Override
public void onDestroy() {
    // I want to restart this service again in one hour
    AlarmManager alarm = (AlarmManager) getSystemService(ALARM_SERVICE);
    alarm.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + (1000 * 60 * 60 * 6),
            PendingIntent.getService(this, 0, new Intent(this, NewsUpdateService.class), 0));
}

From source file:com.orpheusdroid.screenrecorder.RecorderService.java

@TargetApi(24)
private void pauseScreenRecording() {
    mMediaRecorder.pause();/*  w  w w .  ja  v a 2 s .  com*/
    //calculate total elapsed time until pause
    elapsedTime += (System.currentTimeMillis() - startTime);

    //Set Resume action to Notification and update the current notification
    Intent recordResumeIntent = new Intent(this, RecorderService.class);
    recordResumeIntent.setAction(Const.SCREEN_RECORDING_RESUME);
    PendingIntent precordResumeIntent = PendingIntent.getService(this, 0, recordResumeIntent, 0);
    NotificationCompat.Action action = new NotificationCompat.Action(android.R.drawable.ic_media_play,
            getString(R.string.screen_recording_notification_action_resume), precordResumeIntent);
    updateNotification(createNotification(action).setUsesChronometer(false).build(),
            Const.SCREEN_RECORDER_NOTIFICATION_ID);
    Toast.makeText(this, R.string.screen_recording_paused_toast, Toast.LENGTH_SHORT).show();
}