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:li.klass.fhem.appwidget.view.widget.medium.TargetStateWidgetView.java

@Override
protected void fillWidgetView(Context context, RemoteViews view, FhemDevice<?> device,
        WidgetConfiguration widgetConfiguration) {
    String payload = widgetConfiguration.payload.get(1);
    String state = device.getEventMapStateFor(payload);

    view.setTextViewText(R.id.button, state);

    PendingIntent pendingIntent;/* ww w. j a  v  a  2  s.  c  om*/
    if (requiresAdditionalInformation(state)) {
        Intent actionIntent = new Intent(context, TargetStateAdditionalInformationActivity.class);
        actionIntent.putExtra(BundleExtraKeys.DEVICE_NAME, device.getName());
        actionIntent.putExtra(BundleExtraKeys.DEVICE_TARGET_STATE, payload);
        actionIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

        pendingIntent = PendingIntent.getActivity(context, widgetConfiguration.widgetId, actionIntent,
                FLAG_UPDATE_CURRENT);
    } else {
        Intent actionIntent = new Intent(Actions.DEVICE_SET_STATE);
        actionIntent.setClass(context, DeviceIntentService.class);
        actionIntent.putExtra(BundleExtraKeys.DEVICE_NAME, device.getName());
        actionIntent.putExtra(BundleExtraKeys.DEVICE_TARGET_STATE, payload);

        pendingIntent = PendingIntent.getService(context, widgetConfiguration.widgetId, actionIntent,
                FLAG_UPDATE_CURRENT);
    }

    view.setOnClickPendingIntent(R.id.button, pendingIntent);

    openDeviceDetailPageWhenClicking(R.id.main, view, device, widgetConfiguration, context);
}

From source file:com.rks.musicx.services.NotificationHandler.java

public static void buildNotification(MusicXService musicXService, String what) {
    if (musicXService == null) {
        return;/*  w ww  .  j  a  v  a2 s.c o  m*/
    }
    RemoteViews remoteViews = new RemoteViews(musicXService.getPackageName(), R.layout.widget);
    RemoteViews smallremoteView = new RemoteViews(musicXService.getPackageName(), R.layout.small_notification);

    Intent intent = new Intent(musicXService, PlayingActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    PendingIntent pendInt = PendingIntent.getActivity(musicXService, 0, intent,
            PendingIntent.FLAG_UPDATE_CURRENT);
    NotificationCompat.Builder builder = (NotificationCompat.Builder) new NotificationCompat.Builder(
            musicXService).setWhen(System.currentTimeMillis()).setCategory(Intent.CATEGORY_APP_MUSIC)
                    .setPriority(Notification.PRIORITY_DEFAULT).setShowWhen(false).setAutoCancel(true)
                    .setCustomBigContentView(remoteViews).setContent(smallremoteView)
                    .setVisibility(NotificationCompat.VISIBILITY_PUBLIC);
    remoteViews.setOnClickPendingIntent(R.id.item_view, pendInt);
    smallremoteView.setOnClickPendingIntent(R.id.small_item_view, pendInt);
    remoteViews.setTextViewText(R.id.title, musicXService.getsongTitle());
    remoteViews.setTextViewText(R.id.artist, musicXService.getsongArtistName());
    smallremoteView.setTextViewText(R.id.small_title, musicXService.getsongTitle());
    smallremoteView.setTextViewText(R.id.small_artist, musicXService.getsongArtistName());
    FavHelper favHelper = new FavHelper(musicXService);
    if (favHelper.isFavorite(musicXService.getsongId())) {
        remoteViews.setImageViewResource(R.id.action_favorite, R.drawable.ic_action_favorite);
    } else {
        remoteViews.setImageViewResource(R.id.action_favorite, R.drawable.ic_action_favorite_outline);
    }
    if (musicXService.isPlaying()) {
        builder.setSmallIcon(R.drawable.aw_ic_play);
        builder.setOngoing(true);
    } else {
        builder.setSmallIcon(R.drawable.aw_ic_pause);
        builder.setOngoing(false);
    }
    if (what.equals(PLAYSTATE_CHANGED)) {
        if (MediaPlayerSingleton.getInstance().getMediaPlayer().isPlaying()) {
            remoteViews.setImageViewResource(R.id.toggle, R.drawable.aw_ic_play);
            smallremoteView.setImageViewResource(R.id.small_toggle, R.drawable.aw_ic_play);
        } else {
            remoteViews.setImageViewResource(R.id.toggle, R.drawable.aw_ic_pause);
            smallremoteView.setImageViewResource(R.id.small_toggle, R.drawable.aw_ic_pause);
        }
    }
    handler.post(new Runnable() {
        @Override
        public void run() {
            ArtworkUtils.ArtworkLoader(musicXService, 300, 300, musicXService.getsongAlbumName(),
                    musicXService.getsongAlbumID(), new palette() {
                        @Override
                        public void palettework(Palette palette) {
                            int colors[] = Helper.getAvailableColor(musicXService, palette);
                            remoteViews.setInt(R.id.item_view, "setBackgroundColor", colors[0]);
                            remoteViews.setInt(R.id.title, "setTextColor", Color.WHITE);
                            remoteViews.setInt(R.id.artist, "setTextColor", Color.WHITE);
                            smallremoteView.setInt(R.id.small_item_view, "setBackgroundColor", colors[0]);
                            smallremoteView.setInt(R.id.small_title, "setTextColor", Color.WHITE);
                            smallremoteView.setInt(R.id.small_artist, "setTextColor", Color.WHITE);
                        }
                    }, new bitmap() {
                        @Override
                        public void bitmapwork(Bitmap bitmap) {
                            remoteViews.setImageViewBitmap(R.id.artwork, bitmap);
                            smallremoteView.setImageViewBitmap(R.id.small_artwork, bitmap);
                            NotificationManagerCompat.from(musicXService).notify(notificationID,
                                    builder.build());
                        }

                        @Override
                        public void bitmapfailed(Bitmap bitmap) {
                            remoteViews.setImageViewBitmap(R.id.artwork, bitmap);
                            smallremoteView.setImageViewBitmap(R.id.small_artwork, bitmap);
                            NotificationManagerCompat.from(musicXService).notify(notificationID,
                                    builder.build());
                        }
                    });
        }
    });
    controls(remoteViews, smallremoteView, musicXService);
}

From source file:com.perm.DoomPlay.DownloadNotifBuilder.java

public Notification createPaused() {
    Notification notification = new Notification();
    RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.notif_download);

    views.setProgressBar(R.id.progressDownload, 100, 0, false);
    views.setTextViewText(R.id.notifTitle, context.getResources().getString(R.string.paused));
    views.setTextViewText(R.id.notifArtist, track.getArtist() + "-" + track.getTitle());
    views.setImageViewResource(R.id.notifPause, R.drawable.widget_play);

    Intent intentClose = new Intent(PlayingService.actionClose);
    intentClose.putExtra("aid", track.getAid());
    intentClose.setComponent(new ComponentName(context, DownloadingService.class));

    Intent intentPause = new Intent(PlayingService.actionIconPlay);
    intentPause.putExtra("aid", track.getAid());
    intentPause.setComponent(new ComponentName(context, DownloadingService.class));

    views.setOnClickPendingIntent(R.id.notifClose,
            PendingIntent.getService(context, notificationId, intentClose, PendingIntent.FLAG_UPDATE_CURRENT));

    views.setOnClickPendingIntent(R.id.notifPause,
            PendingIntent.getService(context, notificationId, intentPause, PendingIntent.FLAG_UPDATE_CURRENT));

    notification.contentView = views;//  w ww  .  j  a  v  a  2 s.c  om
    notification.flags = Notification.FLAG_ONGOING_EVENT;
    notification.icon = R.drawable.download_icon;

    return notification;
}

From source file:com.perm.DoomPlay.DownloadNotifBuilder.java

private Notification createStartingNew() {
    Notification notification = new Notification();
    RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.notif_download);

    views.setProgressBar(R.id.progressDownload, 100, 0, true);
    views.setTextViewText(R.id.notifTitle, context.getResources().getString(R.string.Downloading));
    views.setTextViewText(R.id.notifArtist, track.getArtist() + "-" + track.getTitle());
    views.setImageViewResource(R.id.notifPause, R.drawable.widget_pause);

    ComponentName componentName = new ComponentName(context, DownloadingService.class);

    Intent intentClose = new Intent(PlayingService.actionClose);
    intentClose.putExtra("aid", track.getAid());
    intentClose.setComponent(componentName);

    Intent intentPause = new Intent(PlayingService.actionIconPause);
    intentPause.putExtra("aid", track.getAid());
    intentPause.setComponent(componentName);

    views.setOnClickPendingIntent(R.id.notifClose,
            PendingIntent.getService(context, notificationId, intentClose, PendingIntent.FLAG_UPDATE_CURRENT));

    views.setOnClickPendingIntent(R.id.notifPause,
            PendingIntent.getService(context, notificationId, intentPause, PendingIntent.FLAG_UPDATE_CURRENT));

    notification.contentView = views;// ww  w.j  av a 2s .c om
    notification.flags = Notification.FLAG_ONGOING_EVENT;
    notification.icon = R.drawable.download_icon;

    return notification;

}

From source file:org.jitsi.android.gui.call.notification.CallNotificationManager.java

/**
 * Displays notification allowing user to control the call directly from
 * the status bar.//  w ww . j a  v a 2s.c  o m
 * @param ctx the Android context.
 * @param callID the ID of call that will be used. The ID is managed by
 * {@link CallManager}.
 */
public synchronized void showCallNotification(Context ctx, final String callID) {
    final Call call = CallManager.getActiveCall(callID);
    if (call == null) {
        throw new IllegalArgumentException("There's no call with id: " + callID);
    }

    NotificationCompat.Builder nBuilder = new NotificationCompat.Builder(ctx)
            .setWhen(System.currentTimeMillis()).setSmallIcon(R.drawable.notificationicon);

    RemoteViews contentView = new RemoteViews(ctx.getPackageName(), R.layout.status_bar_call);

    // Sets call peer display name
    CallPeer callPeer = call.getCallPeers().next();
    contentView.setTextViewText(R.id.calleeDisplayName, callPeer.getDisplayName());

    // Binds pending intents
    setIntents(ctx, contentView, callID);

    // Sets the content view
    nBuilder.setContent(contentView);

    Notification notification = nBuilder.build();

    NotificationManager mNotificationManager = (NotificationManager) ctx
            .getSystemService(Context.NOTIFICATION_SERVICE);

    int id = SystrayServiceImpl.getGeneralNotificationId();
    mNotificationManager.notify(id, notification);

    CtrlNotificationThread notificationHandler = new CtrlNotificationThread(ctx, call, id, notification);

    handlersMap.put(callID, notificationHandler);

    call.addCallChangeListener(new CallChangeListener() {
        public void callPeerAdded(CallPeerEvent evt) {
        }

        public void callPeerRemoved(CallPeerEvent evt) {
            stopNotification(callID);
            call.removeCallChangeListener(this);
        }

        public void callStateChanged(CallChangeEvent evt) {
        }
    });

    // Starts notification update thread
    notificationHandler.start();
}

From source file:com.ultrafunk.network_info.receiver.MobileDataStatusReceiver.java

@Override
protected void updateView(Context context, RemoteViews remoteViews, Bundle widgetOptions) {
    if (isMobileDataEnabled && isMobileOutOfService) {
        setStateColor(context, remoteViews, STATE_ON);
        remoteViews.setTextViewText(R.id.mobileNameTextView, context.getString(R.string.mobile_data));
        remoteViews.setImageViewResource(R.id.mobileStateImageView, R.drawable.ic_signal_cellular_enabled);
        remoteViews.setViewVisibility(R.id.mobileInfoTopTextView, View.VISIBLE);
        remoteViews.setTextViewText(R.id.mobileInfoTopTextView, context.getString(R.string.no_service));
        remoteViews.setViewVisibility(R.id.mobileInfoBottomTextView, View.GONE);
        return;/* ww  w.j  av a  2s.  c  o m*/
    }

    if (dataState == TelephonyManager.DATA_DISCONNECTED) {
        remoteViews.setViewVisibility(R.id.mobileInfoTopTextView, View.VISIBLE);
        remoteViews.setViewVisibility(R.id.mobileInfoBottomTextView, View.VISIBLE);

        if (isMobileDataEnabled && !isAirplaneModeOn) {
            setStateColor(context, remoteViews, STATE_ON);
            remoteViews.setTextViewText(R.id.mobileNameTextView, networkOperatorAndServiceProvider);
            remoteViews.setImageViewResource(R.id.mobileStateImageView, R.drawable.ic_signal_cellular_enabled);
            remoteViews.setTextViewText(R.id.mobileInfoTopTextView, context.getString(R.string.not_connected));
            remoteViews.setTextColor(R.id.mobileInfoBottomTextView,
                    ContextCompat.getColor(context, R.color.medium_gray));
            remoteViews.setTextViewText(R.id.mobileInfoBottomTextView,
                    MobileDataUtils.getDataUsageString(context, NetworkStateService.getDataUsageBytes()));
        } else {
            setStateColor(context, remoteViews, STATE_OFF);
            remoteViews.setTextViewText(R.id.mobileNameTextView,
                    isAirplaneModeOn ? context.getString(R.string.mobile_data)
                            : networkOperatorAndServiceProvider);
            remoteViews.setImageViewResource(R.id.mobileStateImageView, R.drawable.ic_signal_cellular_off);

            if (isAirplaneModeOn) {
                remoteViews.setTextViewText(R.id.mobileInfoTopTextView,
                        context.getString(R.string.flight_mode));
                remoteViews.setViewVisibility(R.id.mobileInfoBottomTextView, View.GONE);
            } else {
                remoteViews.setTextViewText(R.id.mobileInfoTopTextView,
                        MobileDataUtils.getNetworkTypeString(telephonyManager.getNetworkType())
                                + (isDataRoaming ? " - " + context.getString(R.string.roaming) : ""));
                remoteViews.setTextViewText(R.id.mobileInfoBottomTextView,
                        MobileDataUtils.getDataUsageString(context, NetworkStateService.getDataUsageBytes()));
            }
        }
    } else {
        setStateColor(context, remoteViews, STATE_ON);
        remoteViews.setTextViewText(R.id.mobileNameTextView, networkOperatorAndServiceProvider);
        remoteViews.setImageViewResource(R.id.mobileStateImageView, R.drawable.ic_signal_cellular_on);
        remoteViews.setViewVisibility(R.id.mobileInfoTopTextView, View.VISIBLE);
        remoteViews.setTextViewText(R.id.mobileInfoTopTextView,
                MobileDataUtils.getNetworkTypeString(telephonyManager.getNetworkType())
                        + (isDataRoaming ? " - " + context.getString(R.string.roaming) : ""));
        remoteViews.setViewVisibility(R.id.mobileInfoBottomTextView, View.VISIBLE);

        boolean isConnecting = ((dataState == TelephonyManager.DATA_CONNECTING)
                || NetworkStateService.isWaitingForDataUsage());
        remoteViews.setTextViewText(R.id.mobileInfoBottomTextView,
                isConnecting ? context.getString(R.string.connecting)
                        : MobileDataUtils.getDataUsageString(context, dataUsageBytes));
    }
}

From source file:com.freshplanet.nativeExtensions.C2DMBroadcastReceiver.java

/**
 * Get the parameters from the message and create a notification from it.
 * @param context/*from  ww w. java 2  s . c  o  m*/
 * @param intent
 */
public void handleMessage(Context context, Intent intent) {
    try {
        registerResources(context);
        extractColors(context);

        FREContext ctxt = C2DMExtension.context;

        NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);

        // icon is required for notification.
        // @see http://developer.android.com/guide/practices/ui_guidelines/icon_design_status_bar.html

        int icon = notificationIcon;
        long when = System.currentTimeMillis();

        // json string

        String parameters = intent.getStringExtra("parameters");
        String facebookId = null;
        JSONObject object = null;
        if (parameters != null) {
            try {
                object = (JSONObject) new JSONTokener(parameters).nextValue();
            } catch (Exception e) {
                Log.d(TAG, "cannot parse the object");
            }
        }
        if (object != null && object.has("facebookId")) {
            facebookId = object.getString("facebookId");
        }

        CharSequence tickerText = intent.getStringExtra("tickerText");
        CharSequence contentTitle = intent.getStringExtra("contentTitle");
        CharSequence contentText = intent.getStringExtra("contentText");

        Intent notificationIntent = new Intent(context, Class.forName(context.getPackageName() + ".AppEntry"));

        PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0);

        Notification notification = new Notification(icon, tickerText, when);
        notification.flags |= Notification.FLAG_AUTO_CANCEL;
        notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);

        RemoteViews contentView = new RemoteViews(context.getPackageName(), customLayout);

        contentView.setTextViewText(customLayoutTitle, contentTitle);
        contentView.setTextViewText(customLayoutDescription, contentText);

        contentView.setTextColor(customLayoutTitle, notification_text_color);
        contentView.setFloat(customLayoutTitle, "setTextSize",
                notification_title_size_factor * notification_text_size);
        contentView.setTextColor(customLayoutDescription, notification_text_color);
        contentView.setFloat(customLayoutDescription, "setTextSize",
                notification_description_size_factor * notification_text_size);

        if (facebookId != null) {
            Log.d(TAG, "bitmap not null");
            CreateNotificationTask cNT = new CreateNotificationTask();
            cNT.setParams(customLayoutImageContainer, NotifId, nm, notification, contentView);
            String src = "http://graph.facebook.com/" + facebookId + "/picture?type=normal";
            URL url = new URL(src);
            cNT.execute(url);
        } else {
            Log.d(TAG, "bitmap null");
            contentView.setImageViewResource(customLayoutImageContainer, customLayoutImage);
            notification.contentView = contentView;
            nm.notify(NotifId, notification);
        }
        NotifId++;

        if (ctxt != null) {
            parameters = parameters == null ? "" : parameters;
            ctxt.dispatchStatusEventAsync("COMING_FROM_NOTIFICATION", parameters);
        }

    } catch (Exception e) {
        Log.e(TAG, "Error activating application:", e);
    }
}

From source file:com.ultrafunk.network_info.receiver.WifiStatusReceiver.java

@Override
protected void updateView(Context context, RemoteViews remoteViews, Bundle widgetOptions) {
    if ((wifiState == WifiManager.WIFI_STATE_DISABLED) || (wifiState == WifiManager.WIFI_STATE_UNKNOWN)) {
        setStateColor(context, remoteViews, STATE_OFF);
        remoteViews.setTextViewText(R.id.wifiNameTextView, context.getString(R.string.wifi));
        remoteViews.setImageViewResource(R.id.wifiStateImageView, R.drawable.ic_signal_wifi_off);
        remoteViews.setViewVisibility(R.id.wifiInfoTopTextView, View.VISIBLE);
        remoteViews.setTextViewText(R.id.wifiInfoTopTextView, context.getString(R.string.tap_to_change));
        remoteViews.setViewVisibility(R.id.wifiInfoBottomTextView, View.GONE);
    } else if (wifiState == WifiManager.WIFI_STATE_ENABLED) {
        remoteViews.setImageViewResource(R.id.wifiStateImageView, R.drawable.ic_signal_wifi_on);
        remoteViews.setViewVisibility(R.id.wifiInfoTopTextView, View.VISIBLE);

        if (wifiInfo.getIpAddress() != 0) {
            setStateColor(context, remoteViews, STATE_ON);
            remoteViews.setTextViewText(R.id.wifiNameTextView, wifiInfo.getSSID().replace("\"", ""));

            if (!detailsString.isEmpty()) {
                remoteViews.setTextViewText(R.id.wifiInfoTopTextView, detailsString);
                remoteViews.setViewVisibility(R.id.wifiInfoBottomTextView, View.VISIBLE);
                remoteViews.setTextViewText(R.id.wifiInfoBottomTextView,
                        WifiUtils.getIpAddressString(wifiInfo.getIpAddress()));
            }//ww  w  .  ja va2 s  .co m
        } else {
            remoteViews.setViewVisibility(R.id.wifiInfoBottomTextView, View.GONE);

            if (detailedState == NetworkInfo.DetailedState.OBTAINING_IPADDR) {
                remoteViews.setTextViewText(R.id.wifiInfoTopTextView, context.getString(R.string.connecting));
            } else {
                setStateColor(context, remoteViews, STATE_ON);
                remoteViews.setTextViewText(R.id.wifiNameTextView, context.getString(R.string.wifi));
                remoteViews.setImageViewResource(R.id.wifiStateImageView, R.drawable.ic_signal_wifi_enabled);
                remoteViews.setTextViewText(R.id.wifiInfoTopTextView, context.getString(R.string.no_network));
            }
        }
    }
}

From source file:eu.operando.operandoapp.util.NotificationUtil.java

public void displayExfiltratedNotification(Context context, String applicationInfo,
        Set<RequestFilterUtil.FilterType> exfiltrated, int mainNotificationId) {
    try {/*from  w w  w. ja  v  a2  s.com*/
        StringBuilder sb = new StringBuilder();
        for (RequestFilterUtil.FilterType f : exfiltrated) {
            sb.append(f + ", ");
        }
        sb.delete(sb.length() - 2, sb.length() - 1);

        RemoteViews smallContentView = new RemoteViews(context.getPackageName(),
                R.layout.proxy_notification_small);
        smallContentView.setImageViewResource(R.id.image, R.drawable.logo_bevel);
        smallContentView.setTextViewText(R.id.titleTxtView, "Personal Information");
        smallContentView.setTextViewText(R.id.subtitleTxtView, "Expand for more info");

        RemoteViews bigContentView = new RemoteViews(context.getPackageName(),
                R.layout.proxy_notification_large);
        bigContentView.setImageViewResource(R.id.image, R.drawable.logo_bevel);
        bigContentView.setTextViewText(R.id.titleTxtView, "Personal Information");
        bigContentView.setTextViewText(R.id.subtitleTxtView,
                applicationInfo.replaceAll("\\s\\(.*?\\)", "") + " requires access to " + sb);
        bigContentView.setTextViewText(R.id.allowBtn, "Allow");
        bigContentView.setTextViewText(R.id.blockBtn, "Block");

        //get exfiltrated info to string array
        String[] exfiltrated_array = new String[exfiltrated.size()];
        int i = 0;
        for (RequestFilterUtil.FilterType filter_type : exfiltrated) {
            exfiltrated_array[i] = filter_type.name();
            i++;
        }

        //set listeners for notification buttons

        Intent allowIntent = new Intent(context, NotificationActivityReceiver.class);
        allowIntent.setAction("allow");
        Bundle allowBundle = new Bundle();
        allowBundle.putString("appInfo", applicationInfo);
        allowBundle.putInt("notificationId", mainNotificationId);
        allowBundle.putStringArray("exfiltrated", exfiltrated_array);
        allowIntent.putExtras(allowBundle);
        PendingIntent pendingAllowIntent = PendingIntent.getBroadcast(context, mainNotificationId + 1,
                allowIntent, PendingIntent.FLAG_UPDATE_CURRENT);
        bigContentView.setOnClickPendingIntent(R.id.allowBtn, pendingAllowIntent);

        Intent blockIntent = new Intent(context, NotificationActivityReceiver.class);
        blockIntent.setAction("block");
        Bundle blockBundle = new Bundle();
        blockBundle.putString("appInfo", applicationInfo);
        blockBundle.putInt("notificationId", mainNotificationId);
        blockBundle.putStringArray("exfiltrated", exfiltrated_array);
        blockIntent.putExtras(blockBundle);
        PendingIntent pendingBlockIntent = PendingIntent.getBroadcast(context, mainNotificationId + 2,
                blockIntent, PendingIntent.FLAG_UPDATE_CURRENT);
        bigContentView.setOnClickPendingIntent(R.id.blockBtn, pendingBlockIntent);

        Notification.Builder mBuilder = new Notification.Builder(context).setSmallIcon(R.drawable.logo_bevel)
                .setContent(smallContentView);
        Notification proxyNotification = mBuilder.build();
        proxyNotification.defaults |= Notification.DEFAULT_ALL;
        proxyNotification.bigContentView = bigContentView;

        NotificationManager mNotificationManager = (NotificationManager) context
                .getSystemService(Context.NOTIFICATION_SERVICE);
        mNotificationManager.notify(mainNotificationId, proxyNotification);
        DatabaseHelper db = new DatabaseHelper(context);
        db.addPendingNotification(new PendingNotification(applicationInfo,
                TextUtils.join(", ", exfiltrated_array), mainNotificationId));
    } catch (Exception e) {
        Log.d("ERROR", e.getMessage());
    }

}

From source file:de.micmun.android.workdaystarget.DaysLeftService.java

/**
 * Updates the days to target.//from ww  w  . j a v  a  2s . co  m
 */
private void updateDays() {
    AppWidgetManager appManager = AppWidgetManager.getInstance(this);
    ComponentName cName = new ComponentName(getApplicationContext(), DaysLeftProvider.class);
    int[] appIds = appManager.getAppWidgetIds(cName);

    DayCalculator dayCalc = new DayCalculator();
    if (!isOnline()) {
        try {
            Thread.sleep(60000);
        } catch (InterruptedException e) {
            Log.e(TAG, "Interrupted: " + e.getLocalizedMessage());
        }
    }

    for (int appId : appIds) {
        PrefManager pm = new PrefManager(this, appId);
        Calendar target = pm.getTarget();
        boolean[] chkDays = pm.getCheckedDays();
        int days = pm.getLastDiff();

        if (isOnline()) {
            try {
                days = dayCalc.getDaysLeft(target.getTime(), chkDays);
                Map<String, Object> saveMap = new HashMap<String, Object>();
                Long diff = Long.valueOf(days);
                saveMap.put(PrefManager.KEY_DIFF, diff);
                pm.save(saveMap);
            } catch (JSONException e) {
                Log.e(TAG, "ERROR holidays: " + e.getLocalizedMessage());
            }
        } else {
            Log.e(TAG, "No internet connection!");
        }
        RemoteViews rv = new RemoteViews(this.getPackageName(), R.layout.appwidget_layout);
        DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT);
        String targetStr = df.format(target.getTime());
        rv.setTextViewText(R.id.target, targetStr);
        String dayStr = String.format(Locale.getDefault(), "%d %s", days,
                getResources().getString(R.string.unit));
        rv.setTextViewText(R.id.dayCount, dayStr);

        // put widget id into intent
        Intent configIntent = new Intent(this, ConfigActivity.class);
        configIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        configIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        configIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appId);
        configIntent.setData(Uri.parse(configIntent.toUri(Intent.URI_INTENT_SCHEME)));
        PendingIntent pendIntent = PendingIntent.getActivity(this, 0, configIntent,
                PendingIntent.FLAG_UPDATE_CURRENT);
        rv.setOnClickPendingIntent(R.id.widgetLayout, pendIntent);

        // update widget
        appManager.updateAppWidget(appId, rv);
    }
}