Example usage for android.widget RemoteViews setTextViewText

List of usage examples for android.widget RemoteViews setTextViewText

Introduction

In this page you can find the example usage for android.widget RemoteViews setTextViewText.

Prototype

public void setTextViewText(int viewId, CharSequence text) 

Source Link

Document

Equivalent to calling TextView#setText(CharSequence)

Usage

From source file:com.aniruddhc.acemusic.player.Services.AudioPlaybackService.java

/**
 * Builds and returns a fully constructed Notification for devices 
 * on Jelly Bean and above (API 16+)./* w w w. j av a  2  s  .  com*/
 */
@SuppressLint("NewApi")
private Notification buildJBNotification(SongHelper songHelper) {
    mNotificationBuilder = new NotificationCompat.Builder(mContext);
    mNotificationBuilder.setOngoing(true);
    mNotificationBuilder.setAutoCancel(false);
    mNotificationBuilder.setSmallIcon(R.drawable.notif_icon);

    //Open up the player screen when the user taps on the notification.
    Intent launchNowPlayingIntent = new Intent();
    launchNowPlayingIntent.setAction(AudioPlaybackService.LAUNCH_NOW_PLAYING_ACTION);
    PendingIntent launchNowPlayingPendingIntent = PendingIntent.getBroadcast(mContext.getApplicationContext(),
            0, launchNowPlayingIntent, 0);
    mNotificationBuilder.setContentIntent(launchNowPlayingPendingIntent);

    //Grab the notification layouts.
    RemoteViews notificationView = new RemoteViews(mContext.getPackageName(),
            R.layout.notification_custom_layout);
    RemoteViews expNotificationView = new RemoteViews(mContext.getPackageName(),
            R.layout.notification_custom_expanded_layout);

    //Initialize the notification layout buttons.
    Intent previousTrackIntent = new Intent();
    previousTrackIntent.setAction(AudioPlaybackService.PREVIOUS_ACTION);
    PendingIntent previousTrackPendingIntent = PendingIntent.getBroadcast(mContext.getApplicationContext(), 0,
            previousTrackIntent, 0);

    Intent playPauseTrackIntent = new Intent();
    playPauseTrackIntent.setAction(AudioPlaybackService.PLAY_PAUSE_ACTION);
    PendingIntent playPauseTrackPendingIntent = PendingIntent.getBroadcast(mContext.getApplicationContext(), 0,
            playPauseTrackIntent, 0);

    Intent nextTrackIntent = new Intent();
    nextTrackIntent.setAction(AudioPlaybackService.NEXT_ACTION);
    PendingIntent nextTrackPendingIntent = PendingIntent.getBroadcast(mContext.getApplicationContext(), 0,
            nextTrackIntent, 0);

    Intent stopServiceIntent = new Intent();
    stopServiceIntent.setAction(AudioPlaybackService.STOP_SERVICE);
    PendingIntent stopServicePendingIntent = PendingIntent.getBroadcast(mContext.getApplicationContext(), 0,
            stopServiceIntent, 0);

    //Check if audio is playing and set the appropriate play/pause button.
    if (mApp.getService().isPlayingMusic()) {
        notificationView.setImageViewResource(R.id.notification_base_play, R.drawable.btn_playback_pause_light);
        expNotificationView.setImageViewResource(R.id.notification_expanded_base_play,
                R.drawable.btn_playback_pause_light);
    } else {
        notificationView.setImageViewResource(R.id.notification_base_play, R.drawable.btn_playback_play_light);
        expNotificationView.setImageViewResource(R.id.notification_expanded_base_play,
                R.drawable.btn_playback_play_light);
    }

    //Set the notification content.
    expNotificationView.setTextViewText(R.id.notification_expanded_base_line_one, songHelper.getTitle());
    expNotificationView.setTextViewText(R.id.notification_expanded_base_line_two, songHelper.getArtist());
    expNotificationView.setTextViewText(R.id.notification_expanded_base_line_three, songHelper.getAlbum());

    notificationView.setTextViewText(R.id.notification_base_line_one, songHelper.getTitle());
    notificationView.setTextViewText(R.id.notification_base_line_two, songHelper.getArtist());

    //Set the states of the next/previous buttons and their pending intents.
    if (mApp.getService().isOnlySongInQueue()) {
        //This is the only song in the queue, so disable the previous/next buttons.
        expNotificationView.setViewVisibility(R.id.notification_expanded_base_next, View.INVISIBLE);
        expNotificationView.setViewVisibility(R.id.notification_expanded_base_previous, View.INVISIBLE);
        expNotificationView.setOnClickPendingIntent(R.id.notification_expanded_base_play,
                playPauseTrackPendingIntent);

        notificationView.setViewVisibility(R.id.notification_base_next, View.INVISIBLE);
        notificationView.setViewVisibility(R.id.notification_base_previous, View.INVISIBLE);
        notificationView.setOnClickPendingIntent(R.id.notification_base_play, playPauseTrackPendingIntent);

    } else if (mApp.getService().isFirstSongInQueue()) {
        //This is the the first song in the queue, so disable the previous button.
        expNotificationView.setViewVisibility(R.id.notification_expanded_base_previous, View.INVISIBLE);
        expNotificationView.setViewVisibility(R.id.notification_expanded_base_next, View.VISIBLE);
        expNotificationView.setOnClickPendingIntent(R.id.notification_expanded_base_play,
                playPauseTrackPendingIntent);
        expNotificationView.setOnClickPendingIntent(R.id.notification_expanded_base_next,
                nextTrackPendingIntent);

        notificationView.setViewVisibility(R.id.notification_base_previous, View.INVISIBLE);
        notificationView.setViewVisibility(R.id.notification_base_next, View.VISIBLE);
        notificationView.setOnClickPendingIntent(R.id.notification_base_play, playPauseTrackPendingIntent);
        notificationView.setOnClickPendingIntent(R.id.notification_base_next, nextTrackPendingIntent);

    } else if (mApp.getService().isLastSongInQueue()) {
        //This is the last song in the cursor, so disable the next button.
        expNotificationView.setViewVisibility(R.id.notification_expanded_base_previous, View.VISIBLE);
        expNotificationView.setViewVisibility(R.id.notification_expanded_base_next, View.INVISIBLE);
        expNotificationView.setOnClickPendingIntent(R.id.notification_expanded_base_play,
                playPauseTrackPendingIntent);
        expNotificationView.setOnClickPendingIntent(R.id.notification_expanded_base_next,
                nextTrackPendingIntent);

        notificationView.setViewVisibility(R.id.notification_base_previous, View.VISIBLE);
        notificationView.setViewVisibility(R.id.notification_base_next, View.INVISIBLE);
        notificationView.setOnClickPendingIntent(R.id.notification_base_play, playPauseTrackPendingIntent);
        notificationView.setOnClickPendingIntent(R.id.notification_base_next, nextTrackPendingIntent);

    } else {
        //We're smack dab in the middle of the queue, so keep the previous and next buttons enabled.
        expNotificationView.setViewVisibility(R.id.notification_expanded_base_previous, View.VISIBLE);
        expNotificationView.setViewVisibility(R.id.notification_expanded_base_next, View.VISIBLE);
        expNotificationView.setOnClickPendingIntent(R.id.notification_expanded_base_play,
                playPauseTrackPendingIntent);
        expNotificationView.setOnClickPendingIntent(R.id.notification_expanded_base_next,
                nextTrackPendingIntent);
        expNotificationView.setOnClickPendingIntent(R.id.notification_expanded_base_previous,
                previousTrackPendingIntent);

        notificationView.setViewVisibility(R.id.notification_base_previous, View.VISIBLE);
        notificationView.setViewVisibility(R.id.notification_base_next, View.VISIBLE);
        notificationView.setOnClickPendingIntent(R.id.notification_base_play, playPauseTrackPendingIntent);
        notificationView.setOnClickPendingIntent(R.id.notification_base_next, nextTrackPendingIntent);
        notificationView.setOnClickPendingIntent(R.id.notification_base_previous, previousTrackPendingIntent);

    }

    //Set the "Stop Service" pending intents.
    expNotificationView.setOnClickPendingIntent(R.id.notification_expanded_base_collapse,
            stopServicePendingIntent);
    notificationView.setOnClickPendingIntent(R.id.notification_base_collapse, stopServicePendingIntent);

    //Set the album art.
    expNotificationView.setImageViewBitmap(R.id.notification_expanded_base_image, songHelper.getAlbumArt());
    notificationView.setImageViewBitmap(R.id.notification_base_image, songHelper.getAlbumArt());

    //Attach the shrunken layout to the notification.
    mNotificationBuilder.setContent(notificationView);

    //Build the notification object.
    Notification notification = mNotificationBuilder.build();

    //Attach the expanded layout to the notification and set its flags.
    notification.bigContentView = expNotificationView;
    notification.flags = Notification.FLAG_FOREGROUND_SERVICE | Notification.FLAG_NO_CLEAR
            | Notification.FLAG_ONGOING_EVENT;

    return notification;
}

From source file:com.andrew.apolloMod.service.ApolloService.java

/** Return notification remote views
 * /*ww w  .  j a  v a 2s . co m*/
 * @return [views, bigViews]
 */
public RemoteViews[] getNotificationViews() {
    Bitmap b = getAlbumBitmap();

    RemoteViews bigViews = new RemoteViews(getPackageName(), R.layout.status_bar_expanded);
    RemoteViews views = new RemoteViews(getPackageName(), R.layout.status_bar);

    if (b != null) {
        bigViews.setImageViewBitmap(R.id.status_bar_album_art, b);
        views.setViewVisibility(R.id.status_bar_icon, View.GONE);
        views.setViewVisibility(R.id.status_bar_album_art, View.VISIBLE);
        views.setImageViewBitmap(R.id.status_bar_album_art, b);
    } else {
        views.setViewVisibility(R.id.status_bar_icon, View.VISIBLE);
        views.setViewVisibility(R.id.status_bar_album_art, View.GONE);
    }

    ComponentName rec = new ComponentName(getPackageName(), MediaButtonIntentReceiver.class.getName());
    Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);
    mediaButtonIntent.putExtra(CMDNOTIF, 1);
    mediaButtonIntent.setComponent(rec);
    KeyEvent mediaKey = new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE);
    mediaButtonIntent.putExtra(Intent.EXTRA_KEY_EVENT, mediaKey);
    PendingIntent mediaPendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 1, mediaButtonIntent,
            PendingIntent.FLAG_UPDATE_CURRENT);

    views.setOnClickPendingIntent(R.id.status_bar_play, mediaPendingIntent);
    bigViews.setOnClickPendingIntent(R.id.status_bar_play, mediaPendingIntent);

    mediaButtonIntent.putExtra(CMDNOTIF, 2);
    mediaKey = new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MEDIA_NEXT);
    mediaButtonIntent.putExtra(Intent.EXTRA_KEY_EVENT, mediaKey);
    mediaPendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 2, mediaButtonIntent,
            PendingIntent.FLAG_UPDATE_CURRENT);

    views.setOnClickPendingIntent(R.id.status_bar_next, mediaPendingIntent);
    bigViews.setOnClickPendingIntent(R.id.status_bar_next, mediaPendingIntent);

    mediaButtonIntent.putExtra(CMDNOTIF, 4);
    mediaKey = new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MEDIA_PREVIOUS);
    mediaButtonIntent.putExtra(Intent.EXTRA_KEY_EVENT, mediaKey);
    mediaPendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 4, mediaButtonIntent,
            PendingIntent.FLAG_UPDATE_CURRENT);

    bigViews.setOnClickPendingIntent(R.id.status_bar_prev, mediaPendingIntent);

    mediaButtonIntent.putExtra(CMDNOTIF, 3);
    mediaKey = new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MEDIA_STOP);
    mediaButtonIntent.putExtra(Intent.EXTRA_KEY_EVENT, mediaKey);
    mediaPendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 3, mediaButtonIntent,
            PendingIntent.FLAG_UPDATE_CURRENT);

    views.setOnClickPendingIntent(R.id.status_bar_collapse, mediaPendingIntent);
    bigViews.setOnClickPendingIntent(R.id.status_bar_collapse, mediaPendingIntent);

    views.setImageViewResource(R.id.status_bar_play, R.drawable.apollo_holo_dark_pause);
    bigViews.setImageViewResource(R.id.status_bar_play, R.drawable.apollo_holo_dark_pause);

    views.setTextViewText(R.id.status_bar_track_name, getTrackName());
    bigViews.setTextViewText(R.id.status_bar_track_name, getTrackName());

    views.setTextViewText(R.id.status_bar_artist_name, getArtistName());
    bigViews.setTextViewText(R.id.status_bar_artist_name, getArtistName());

    bigViews.setTextViewText(R.id.status_bar_album_name, getAlbumName());

    return new RemoteViews[] { views, bigViews };

}

From source file:saphion.services.ForegroundService.java

@SuppressWarnings("deprecation")
void handleCommand() {

    mPref = getSharedPreferences(PREF_NAME, MODE_MULTI_PROCESS);

    // if (ACTION_FOREGROUND.equals(intent.getAction())) {
    // In this sample, we'll use the same text for the ticker and the
    // expanded notification
    // CharSequence text = getText(R.string.foreground_service_started);

    // Set the icon, scrolling text and timestamp
    try {//from   w  w w . ja  va  2  s  .c om
        handleTrigger(level);
    } catch (Exception ex) {
        Log.d(ex.toString());
    }

    RemoteViews rvNoti = new RemoteViews(getPackageName(), R.layout.smallnoti);

    NotificationCompat.Builder builder;/*
                                       * = new NotificationCompat.Builder(
                                       * getBaseContext
                                       * ()).setContent(rvNoti);
                                       * builder.build();
                                       */

    Notification notification = new Notification(getId(level), null, 0);

    // The PendingIntent to launch our activity if the user selects this
    // notification
    PendingIntent contentIntent = null;
    Intent localIntent;
    switch (mPref.getInt(PreferenceHelper.NOTI_ONCLICK, 2)) {
    case 0:
        contentIntent = PendingIntent.getActivity(this, 0, new Intent(this, TabNavigation.class), 0);
        break;
    case 1:
        localIntent = new Intent();
        localIntent.setFlags(346030080);
        localIntent.setAction("android.intent.action.POWER_USAGE_SUMMARY");
        contentIntent = PendingIntent.getActivity(this, 0, localIntent, 0);
        break;
    case 2:
        contentIntent = PendingIntent.getActivity(this, 0, new Intent(this, Controller.class), 0);
        break;
    case 3:
        contentIntent = PendingIntent.getActivity(this, 0, new Intent(this, ToggleDialog.class), 0);
        break;
    }
    String prevTime = mPref.getString(PreferenceHelper.PREV_BAT_TIME, TimeFuncs.getCurrentTimeStamp());

    long diff = TimeFuncs.newDiff(TimeFuncs.GetItemDate(prevTime),
            TimeFuncs.GetItemDate(TimeFuncs.getCurrentTimeStamp()));

    Log.d("New diff " + diff);
    // TODO

    Log.d("Previous Date: " + TimeFuncs.GetItemDate(prevTime));
    Log.d("Current Date: " + TimeFuncs.GetItemDate(TimeFuncs.getCurrentTimeStamp()));
    // Log.d( "Previous Timestamp " + level + "");
    // Log.d( "Current Timestamp " + level + "");

    String subtext;

    Log.d("Current Level " + level + "");
    Log.d("Previous Level " + mPref.getInt(PreferenceHelper.PREV_BAT_LEVEL, level) + "");
    if (level < mPref.getInt(PreferenceHelper.PREV_BAT_LEVEL, level)) {

        diff = (long) (mPref.getLong(PreferenceHelper.BAT_DISCHARGE, diff));

        reqTime = diff * level;
        subtext = "Empty in " + TimeFuncs.convtohournminnday(reqTime);

        // mPref
        // .edit().putLong(PreferenceHelper.BAT_DISCHARGE, diff)
        // .commit();
        Log.d("Discharging with " + diff);

    } else {
        if (level > mPref.getInt(PreferenceHelper.PREV_BAT_LEVEL, level)) {
            if (level != 100
                    && TimeFuncs.convtohournminnday(diff * (100 - level)).equalsIgnoreCase("0 Minute(s)")) {
                reqTime = (long) (81 * (100 - level));
                subtext = "Full Charge in " + TimeFuncs.convtohournminnday(reqTime);
            } else {
                reqTime = diff * (100 - level);
                subtext = "Full Charge in " + TimeFuncs.convtohournminnday(reqTime);
                mPref.edit().putLong(PreferenceHelper.BAT_CHARGE, diff).commit();
            }

            Log.d("Charging with " + diff);

        } else {

            if (isconnected) {
                reqTime = (long) (mPref.getLong(PreferenceHelper.BAT_CHARGE, 81) * (100 - level));
                subtext = "Full Charge in " + TimeFuncs.convtohournminnday(reqTime);
                Log.d("Estimating Charging");
                // mPref
                // .edit().putLong("batcharge", diff).commit();
                Log.d("EST Charging with " + diff);

            } else {
                reqTime = (long) (mPref.getLong(PreferenceHelper.BAT_DISCHARGE, 792) * (level));
                subtext = "Empty in " + TimeFuncs.convtohournminnday(reqTime);
                Log.d("Estimating Discharging with: "
                        + (long) (mPref.getLong(PreferenceHelper.BAT_DISCHARGE, 792)));
            }
        }
    }

    if (level == 100 && isconnected) {
        subtext = "Fully Charged";
        reqTime = 0;
    }

    String mainText = mPref.getString(PreferenceHelper.LAST_CHARGED, TimeFuncs.getCurrentTimeStamp());

    if (isconnected) {
        if (mPref.getBoolean("plugged?", true))
            mPref.edit().putString(PreferenceHelper.LAST_CHARGED, TimeFuncs.getCurrentTimeStamp()).commit();
        String time = TimeFuncs.convtohournminnday(TimeFuncs.newDiff(TimeFuncs.GetItemDate(mainText),
                TimeFuncs.GetItemDate(TimeFuncs.getCurrentTimeStamp())));
        if (!time.equals("0 Minute(s)"))
            mainText = "Plugged " + time + " ago";
        else
            mainText = "Plugged " + "right now";
        mPref.edit().putBoolean("plugged?", false).commit();

    } else {
        if (!mPref.getBoolean("plugged?", true)) {
            mPref.edit().putBoolean("plugged?", true).commit();
            mPref.edit().putString(PreferenceHelper.LAST_CHARGED, TimeFuncs.getCurrentTimeStamp()).commit();
        }

        mainText = mPref.getString(PreferenceHelper.LAST_CHARGED, TimeFuncs.getCurrentTimeStamp());

        String time = TimeFuncs.convtohournminnday(TimeFuncs.newDiff(TimeFuncs.GetItemDate(mainText),
                TimeFuncs.GetItemDate(TimeFuncs.getCurrentTimeStamp())));

        if (!time.equals("0 Minute(s)"))
            mainText = "Unplugged " + time + " ago";
        else
            mainText = "Unplugged " + "right now";
    }

    String tempsubtext = subtext;
    subtext = setNotText(subtext, mainText, mPref.getInt(PreferenceHelper.NOTI_SUBTEXT, 3));
    mainText = setNotText(tempsubtext, mainText, mPref.getInt(PreferenceHelper.NOTI_MAINTEXT, 6));

    // Set the info for the views that show in the notification panel
    int srcId = getId(level);
    builder = new NotificationCompat.Builder(this).setSmallIcon(srcId).setAutoCancel(false).setOngoing(true)
            .setContentTitle(mainText).setContentText(subtext).setTicker(null).setWhen(0);
    // modification

    rvNoti.setImageViewResource(R.id.notification_icon, srcId);
    rvNoti.setTextViewText(R.id.tvNotiPrevmainText, mainText);
    rvNoti.setTextViewText(R.id.tvNotiPrevsubText, subtext);

    rvLargeNoti = new RemoteViews(getPackageName(), R.layout.largenoti);

    /*if (Build.VERSION.SDK_INT != 20)*/
    builder.setContent(rvNoti);
    // Intent notificationIntent = new Intent(this,
    // ForegroundService.class);
    // contentIntent = PendingIntent.getActivity(this, 0,
    // notificationIntent,
    // PendingIntent.FLAG_UPDATE_CURRENT);
    builder.setContentIntent(contentIntent);
    switch (mPref.getInt(PreferenceHelper.NOTI_PRIORITY, 2)) {
    case 0:
        builder.setPriority(NotificationCompat.PRIORITY_HIGH);
        break;
    case 1:
        builder.setPriority(NotificationCompat.PRIORITY_MIN);
        break;
    case 2:
        builder.setPriority(NotificationCompat.PRIORITY_DEFAULT);
        break;
    case 3:
        builder.setPriority(NotificationCompat.PRIORITY_LOW);
        break;
    case 4:
        builder.setPriority(NotificationCompat.PRIORITY_MAX);
        break;
    }

    // builder.
    notification = builder.build();
    /*if (Build.VERSION.SDK_INT != 20)*/
    notification.contentView = rvNoti;

    /*if (Build.VERSION.SDK_INT == 20) {
            
               
        * builder = new
        * Notification.Builder(this).setContentTitle(mainText)
        * .setContentText(subtext).setTicker(null).setWhen(0)
        * .setOngoing(true).setSmallIcon(srcId)
        * .setContentIntent(pendingIntent).addAction(call)
        * .addAction(cancel).setAutoCancel(false);
                
            
       setKitkatActions(builder);
            
       notification = builder.build();
            
    } else*/ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        rvLargeNoti.setImageViewResource(R.id.notification_icon_large, srcId);

        if (mPref.getBoolean(PreferenceHelper.SHOW_CHART, true)) {

            vals = new ArrayList<Double>();
            dates = new ArrayList<Double>();

            vals = SerialPreference.retPrefs(getBaseContext(), PreferenceHelper.BAT_VALS);
            dates = SerialPreference.retPrefs(getBaseContext(), PreferenceHelper.BAT_TIME);

            GraphicalView mChartView = ChartFactory.getTimeChartView(getBaseContext(), getDateDataset(),
                    getRenderer(), "EEE, h:mm a");
            Bitmap outBitmap = Bitmap.createScaledBitmap(loadBitmapFromView(mChartView),
                    getResources().getDisplayMetrics().widthPixels,
                    Functions.ReturnHeight(140, getBaseContext()), true);

            rvLargeNoti.setImageViewBitmap(R.id.ivchart_large, outBitmap);
            rvLargeNoti.setViewVisibility(R.id.ivchart_large, View.VISIBLE);
        } else {
            rvLargeNoti.setViewVisibility(R.id.ivchart_large, View.GONE);
        }
        rvLargeNoti.setTextViewText(R.id.tvNotiPrevmainText_large, mainText);
        rvLargeNoti.setTextViewText(R.id.tvNotiPrevsubText_large, subtext);
        setResourceImages(rvLargeNoti);
        setIntents(rvLargeNoti);
        notification.bigContentView = rvLargeNoti;

    }

    if (mPref.getBoolean(PreferenceHelper.NOTIFICATION_ENABLE, true)) {
        /*
         * startForegroundCompat(R.string.foreground_service_started,
         * notification);
         */
        startForeground(notiID, notification);

    } else {
        notification.icon = R.drawable.abc_ab_bottom_transparent_dark_holo;
        try {
            if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN)
                notification.priority = Notification.PRIORITY_MIN;
        } catch (Exception ex) {
        }
        startForeground(notiID, notification);
        startService(new Intent(ForegroundService.this, FakeService.class));
    }

    /*
     * if(DISPLAY != null){ if(DISPLAY){ startForeground(notiID,
     * notification); Log.Toast(getBaseContext(), "displaying notification",
     * Toast.LENGTH_LONG); }else{ Log.Toast(getBaseContext(),
     * "not gonna display", Toast.LENGTH_LONG);
     * //startForegroundCompat(R.string.foreground_service_started, null);
     * notification.icon = R.drawable.abc_ab_bottom_transparent_dark_holo;
     * notification.priority = Notification.PRIORITY_MIN;
     * startForeground(notiID, notification); startService(new
     * Intent(ForegroundService.this, FakeService.class)); } }
     */

    if (level != mPref.getInt(PreferenceHelper.PREV_BAT_LEVEL, level))
        mPref.edit().putString(PreferenceHelper.PREV_BAT_TIME, TimeFuncs.getCurrentTimeStamp()).commit();
    mPref.edit().putInt(PreferenceHelper.PREV_BAT_LEVEL, level).commit();

}