Example usage for android.widget RemoteViews RemoteViews

List of usage examples for android.widget RemoteViews RemoteViews

Introduction

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

Prototype

public RemoteViews(RemoteViews landscape, RemoteViews portrait) 

Source Link

Document

Create a new RemoteViews object that will inflate as the specified landspace or portrait RemoteViews, depending on the current configuration.

Usage

From source file:io.github.dector.rkpi.components.notifications.NotificationManager.java

/**
 * Create new instance//from  w w w  .  j a  va2 s.  c  om
 *
 * @param context application context
 */
public NotificationManager(Context context) {
    mContext = context;

    mManager = (android.app.NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);

    int icon = R.drawable.icon_bar;

    PendingIntent contentIntent = PendingIntent.getActivity(context, 0, new Intent(context, MainActivity.class),
            PendingIntent.FLAG_UPDATE_CURRENT);

    PendingIntent playPauseIntent = PendingIntent.getBroadcast(context, 0,
            new Intent(Request.PLAYER_TOGGLE.encode()), PendingIntent.FLAG_UPDATE_CURRENT);

    PendingIntent exitIntent = PendingIntent.getBroadcast(context, 0, new Intent(Request.EXIT.encode()),
            PendingIntent.FLAG_CANCEL_CURRENT);

    mRemoteViews = new RemoteViews(context.getPackageName(), R.layout.notification_layout);
    mRemoteViews.setOnClickPendingIntent(R.id.toggleButton, playPauseIntent);
    mRemoteViews.setOnClickPendingIntent(R.id.closeButton, exitIntent);

    mNotificationBuilder = new NotificationCompat.Builder(context).setSmallIcon(icon).setContent(mRemoteViews)
            .setContentIntent(contentIntent).setOngoing(true);
}

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

/**
 * Updates the days to target./*  ww  w .  j  a va  2 s .c o  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);
    }
}

From source file:com.shanet.relayremote.Background.java

protected void onPostExecute(ArrayList<BasicNameValuePair> states) {
    // Dismiss the dialog and cancel the timer
    if (!isWidget) {
        dialog.dismiss();//from   ww w  .j  ava2s .c o  m
        tt.cancel();
    }

    // If the context is an instance of the main activity, update the state of the relays in the listview
    if (!isWidget && (Activity) context instanceof Main && states.size() > 1) {
        ((Main) context).setRelaysAndGroupsStates(states);
        // If a widget, update the indicator light and states map 
    } else if (isWidget) {
        for (int i = 1; i < states.size(); i++) {
            if (pin == Integer.valueOf(states.get(i).getName())) {
                // Update the indicator image
                RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget);
                views.setImageViewResource(R.id.widgetIndicator,
                        (states.get(i).getValue().charAt(0) == Constants.CMD_ON) ? R.drawable.widget_on
                                : R.drawable.widget_off);
                AppWidgetManager.getInstance(context).updateAppWidget(appWidgetId, views);

                // Set the state of the widget in the widget class
                Widget.setState(appWidgetId,
                        (states.get(i).getValue().charAt(0) == Constants.CMD_ON) ? Widget.STATE_ON
                                : Widget.STATE_OFF);
            }
        }
    }
}

From source file:com.ratusapparatus.tapsaff.TapsAff.java

protected void onPostExecute(String feed) {
    ComponentName thisWidget = new ComponentName(context, TapsAff.class);
    RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget_layout);

    Log.i("tapsaffonPostExecuteFeed", feed);
    JSONObject jsonObj;//w w w  .  ja va2  s .  c o m
    try {
        jsonObj = new JSONObject(feed);
        /*for (int i = 0; i < jsonArray.length(); i++)
        {
        JSONObject jsonObject = jsonArray.getJSONObject(i);
        Log.i(TapsAff.class.getName(), jsonObject.getString("text"));
        }*/
        String oanAff = jsonObj.get("taps").toString();
        Integer itsClose = (Integer) jsonObj.get("temp_f");
        if (itsClose >= TapsAff.tapsTemp - 5 && itsClose <= TapsAff.tapsTemp)
            views.setViewVisibility(R.id.bottom, View.VISIBLE);
        else
            views.setViewVisibility(R.id.bottom, View.GONE);
        String colour = "blue";
        if (oanAff == "Aff")
            colour = "red";
        String text = "taps" + " " + "<font color='" + colour + "'>" + oanAff + "</font>";
        //textView.setText(, TextView.BufferType.SPANNABLE);
        views.setTextViewText(R.id.main, Html.fromHtml(text));
    } catch (Exception e) {
        Log.i("tapsaffonPostExecuteException", e.getLocalizedMessage());
    }
    appWidgetManager.updateAppWidget(thisWidget, views);
}

From source file:com.tortel.deploytrack.service.NotificationService.java

@SuppressLint("NewApi")
private void showNotification() {
    // If there isnt an ID saved, shut down the service
    if (deploymentId == -1) {
        stopSelf();/*from  w  w w. j av a2  s .c om*/
        return;
    }
    if (DEBUG) {
        Toast.makeText(this, "NotificationService loading notification", Toast.LENGTH_SHORT).show();
    }

    // Load the Deployment object
    Deployment deployment = DatabaseManager.getInstance(this).getDeployment(deploymentId);
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);

    RemoteViews view = new RemoteViews(getPackageName(), R.layout.notification);
    view.setImageViewBitmap(R.id.notification_pie, WidgetProvider.getChartBitmap(deployment, SIZE));
    view.setTextViewText(R.id.notification_title, deployment.getName());

    view.setTextViewText(R.id.notification_main, getResources().getString(R.string.small_notification,
            deployment.getPercentage(), deployment.getCompleted(), deployment.getLength()));

    if (prefs.getBoolean(Prefs.KEY_HIDE_DATE, false)) {
        view.setViewVisibility(R.id.notification_daterange, View.GONE);
    } else {
        view.setTextViewText(R.id.notification_daterange, getResources().getString(R.string.date_range,
                deployment.getFormattedStart(), deployment.getFormattedEnd()));
    }

    NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
    builder.setContentTitle(deployment.getName());
    builder.setContentText(getResources().getString(R.string.small_notification, deployment.getPercentage(),
            deployment.getCompleted(), deployment.getLength()));
    builder.setOngoing(true);

    // Hide the time, its persistent
    builder.setWhen(0);

    builder.setSmallIcon(R.drawable.ic_notification);
    builder.setPriority(Integer.MAX_VALUE);

    Notification notification = builder.build();

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        notification.bigContentView = view;
    }

    notificationManager.notify(NOTIFICATION_ID, notification);

    //Schedule an update at midnight
    AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
    DateTime now = new DateTime();
    DateTime tomorrow = new DateTime(now.plusDays(1)).withTimeAtStartOfDay();

    PendingIntent pending = PendingIntent.getBroadcast(getBaseContext(), 0, new Intent(UPDATE_INTENT),
            PendingIntent.FLAG_UPDATE_CURRENT);

    //Adding 100msec to make sure its triggered after midnight
    Log.d("Scheduling notification update for " + tomorrow.getMillis() + 100);

    if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN_MR2) {
        alarmManager.setExact(AlarmManager.RTC, tomorrow.getMillis() + 100, pending);
    } else {
        alarmManager.set(AlarmManager.RTC, tomorrow.getMillis() + 100, pending);
    }
}

From source file:io.teak.sdk.NotificationBuilder.java

public static Notification createNativeNotification(final Context context, Bundle bundle,
        TeakNotification teakNotificaton) {
    NotificationCompat.Builder builder = new NotificationCompat.Builder(context);

    // Rich text message
    Spanned richMessageText = Html.fromHtml(teakNotificaton.message);

    // Configure notification behavior
    builder.setPriority(NotificationCompat.PRIORITY_MAX);
    builder.setDefaults(NotificationCompat.DEFAULT_ALL);
    builder.setOnlyAlertOnce(true);// w  ww  .  ja v a  2 s .c  o m
    builder.setAutoCancel(true);
    builder.setTicker(richMessageText);

    // Set small view image
    try {
        PackageManager pm = context.getPackageManager();
        ApplicationInfo ai = pm.getApplicationInfo(context.getPackageName(), 0);
        builder.setSmallIcon(ai.icon);
    } catch (Exception e) {
        Log.e(LOG_TAG, "Unable to load icon resource for Notification.");
        return null;
    }

    Random rng = new Random();

    // Create intent to fire if/when notification is cleared
    Intent pushClearedIntent = new Intent(
            context.getPackageName() + TeakNotification.TEAK_NOTIFICATION_CLEARED_INTENT_ACTION_SUFFIX);
    pushClearedIntent.putExtras(bundle);
    PendingIntent pushClearedPendingIntent = PendingIntent.getBroadcast(context, rng.nextInt(),
            pushClearedIntent, PendingIntent.FLAG_ONE_SHOT);
    builder.setDeleteIntent(pushClearedPendingIntent);

    // Create intent to fire if/when notification is opened, attach bundle info
    Intent pushOpenedIntent = new Intent(
            context.getPackageName() + TeakNotification.TEAK_NOTIFICATION_OPENED_INTENT_ACTION_SUFFIX);
    pushOpenedIntent.putExtras(bundle);
    PendingIntent pushOpenedPendingIntent = PendingIntent.getBroadcast(context, rng.nextInt(), pushOpenedIntent,
            PendingIntent.FLAG_ONE_SHOT);
    builder.setContentIntent(pushOpenedPendingIntent);

    // Because we can't be certain that the R class will line up with what is at SDK build time
    // like in the case of Unity et. al.
    class IdHelper {
        public int id(String identifier) {
            int ret = context.getResources().getIdentifier(identifier, "id", context.getPackageName());
            if (ret == 0) {
                throw new Resources.NotFoundException("Could not find R.id." + identifier);
            }
            return ret;
        }

        public int layout(String identifier) {
            int ret = context.getResources().getIdentifier(identifier, "layout", context.getPackageName());
            if (ret == 0) {
                throw new Resources.NotFoundException("Could not find R.layout." + identifier);
            }
            return ret;
        }
    }
    IdHelper R = new IdHelper(); // Declaring local as 'R' ensures we don't accidentally use the other R

    // Configure notification small view
    RemoteViews smallView = new RemoteViews(context.getPackageName(),
            Build.VERSION.SDK_INT >= Build.VERSION_CODES.M ? R.layout("teak_notif_no_title_v21")
                    : R.layout("teak_notif_no_title"));

    // Set small view image
    try {
        PackageManager pm = context.getPackageManager();
        ApplicationInfo ai = pm.getApplicationInfo(context.getPackageName(), 0);
        smallView.setImageViewResource(R.id("left_image"), ai.icon);
        builder.setSmallIcon(ai.icon);
    } catch (Exception e) {
        Log.e(LOG_TAG, "Unable to load icon resource for Notification.");
        return null;
    }

    // Set small view text
    smallView.setTextViewText(R.id("text"), richMessageText);

    // Check for Jellybean (API 16, 4.1)+ for expanded view
    RemoteViews bigView = null;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN && teakNotificaton.longText != null
            && !teakNotificaton.longText.isEmpty()) {
        bigView = new RemoteViews(context.getPackageName(),
                Build.VERSION.SDK_INT >= Build.VERSION_CODES.M ? R.layout("teak_big_notif_image_text_v21")
                        : R.layout("teak_big_notif_image_text"));

        // Set big view text
        bigView.setTextViewText(R.id("text"), Html.fromHtml(teakNotificaton.longText));

        URI imageAssetA = null;
        try {
            imageAssetA = new URI(teakNotificaton.imageAssetA);
        } catch (Exception ignored) {
        }

        Bitmap topImageBitmap = null;
        if (imageAssetA != null) {
            try {
                URL aURL = new URL(imageAssetA.toString());
                URLConnection conn = aURL.openConnection();
                conn.connect();
                InputStream is = conn.getInputStream();
                BufferedInputStream bis = new BufferedInputStream(is);
                topImageBitmap = BitmapFactory.decodeStream(bis);
                bis.close();
                is.close();
            } catch (Exception ignored) {
            }
        }

        if (topImageBitmap == null) {
            try {
                InputStream istr = context.getAssets().open("teak_notif_large_image_default.png");
                topImageBitmap = BitmapFactory.decodeStream(istr);
            } catch (Exception ignored) {
            }
        }

        if (topImageBitmap != null) {
            // Set large bitmap
            bigView.setImageViewBitmap(R.id("top_image"), topImageBitmap);
        } else {
            Log.e(LOG_TAG, "Unable to load image asset for Notification.");
            // Hide pulldown
            smallView.setViewVisibility(R.id("pulldown_layout"), View.INVISIBLE);
        }
    } else {
        // Hide pulldown
        smallView.setViewVisibility(R.id("pulldown_layout"), View.INVISIBLE);
    }

    // Voodoo from http://stackoverflow.com/questions/28169474/notification-background-in-android-lollipop-is-white-can-we-change-it
    int topId = Resources.getSystem().getIdentifier("status_bar_latest_event_content", "id", "android");
    int topBigLayout = Resources.getSystem().getIdentifier("notification_template_material_big_media_narrow",
            "layout", "android");
    int topSmallLayout = Resources.getSystem().getIdentifier("notification_template_material_media", "layout",
            "android");

    RemoteViews topBigView = null;
    if (bigView != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        // This is invisible inner view - to have media_actions in hierarchy
        RemoteViews innerTopView = new RemoteViews("android", topBigLayout);
        bigView.addView(android.R.id.empty, innerTopView);

        // This should be on top - we need status_bar_latest_event_content as top layout
        topBigView = new RemoteViews("android", topBigLayout);
        topBigView.removeAllViews(topId);
        topBigView.addView(topId, bigView);
    } else if (bigView != null) {
        topBigView = bigView;
    }

    // This should be on top - we need status_bar_latest_event_content as top layout
    RemoteViews topSmallView;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        topSmallView = new RemoteViews("android", topSmallLayout);
        topSmallView.removeAllViews(topId);
        topSmallView.addView(topId, smallView);
    } else {
        topSmallView = smallView;
    }

    builder.setContent(topSmallView);

    Notification n = builder.build();
    if (topBigView != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        // Use reflection to avoid compile-time issues, we check minimum API version above
        try {
            Field bigContentViewField = n.getClass().getField("bigContentView");
            bigContentViewField.set(n, topBigView);
        } catch (Exception ignored) {
        }
    }

    return n;
}

From source file:com.fastbootmobile.encore.service.ServiceNotification.java

private void buildRemoteViews() {
    mBaseTemplate = new RemoteViews(mContext.getPackageName(), R.layout.notification_base);
    mExpandedTemplate = new RemoteViews(mContext.getPackageName(), R.layout.notification_expanded);

    // Setup pending intents
    PendingIntent piNext = PendingIntent.getService(mContext, 0, NotifActionService.getIntentNext(mContext), 0);
    PendingIntent piPrevious = PendingIntent.getService(mContext, 0,
            NotifActionService.getIntentPrevious(mContext), 0);
    PendingIntent piPause = PendingIntent.getService(mContext, 0,
            NotifActionService.getIntentTogglePause(mContext), 0);
    PendingIntent piStop = PendingIntent.getService(mContext, 0, NotifActionService.getIntentStop(mContext), 0);

    mBaseTemplate.setOnClickPendingIntent(R.id.btnNotifNext, piNext);
    mExpandedTemplate.setOnClickPendingIntent(R.id.btnNotifNext, piNext);
    mBaseTemplate.setOnClickPendingIntent(R.id.btnNotifPlayPause, piPause);
    mExpandedTemplate.setOnClickPendingIntent(R.id.btnNotifPlayPause, piPause);
    mBaseTemplate.setOnClickPendingIntent(R.id.btnNotifPrevious, piPrevious);
    mExpandedTemplate.setOnClickPendingIntent(R.id.btnNotifPrevious, piPrevious);
    mBaseTemplate.setOnClickPendingIntent(R.id.btnNotifClose, piStop);
    mExpandedTemplate.setOnClickPendingIntent(R.id.btnNotifClose, piStop);
}

From source file:com.open.file.manager.CutCopyService.java

/**
 * Notify some error has occurred with notification
 * @param errorRes resource to show/*w  w  w. j  a  v  a2  s .  c  o m*/
 */
private void notifyError(int errorRes) {
    String errformat, errstring;
    stopForeground(true);
    errformat = getResources().getString(errorRes);
    errstring = String.format(errformat, getResources().getString(actions[currentaction]));
    cutcopynotification = new Notification();
    cutcopynotification.contentView = new RemoteViews(getApplicationContext().getPackageName(),
            R.layout.errornot);
    cutcopynotification.contentView.setTextViewText(R.id.errortext, errstring);
    cutcopynotification.contentIntent = contentIntent;
    cutcopynotification.icon = R.drawable.error;
    cutcopymanager.notify(completeid, cutcopynotification);
}

From source file:com.teclib.service.MQTTNotificationService.java

public void CustomNotificationConnected(String title) {
    RemoteViews remoteViews = new RemoteViews(getPackageName(), R.layout.notification_mqtt_connect);

    String strtitle = getString(R.string.app_name);

    Intent intent = new Intent(this, MQTTNotifierActivity.class);

    intent.putExtra("title", strtitle);
    intent.putExtra("text", title);

    PendingIntent pIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);

    NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
            .setSmallIcon(R.mipmap.ic_white_stork).setTicker(getString(R.string.enrolement_string))
            .setContentIntent(pIntent).setOngoing(true).setContent(remoteViews);

    remoteViews.setImageViewResource(R.id.imagenotileft, R.mipmap.ic_notification_connect);
    remoteViews.setTextViewText(R.id.title, getString(R.string.app_name));
    remoteViews.setTextViewText(R.id.text, title);

    NotificationManager notificationmanager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    notificationmanager.notify(1, builder.build());

}

From source file:com.sip.pwc.sipphone.service.Downloader.java

@Override
protected void onHandleIntent(Intent intent) {
    HttpGet getMethod = new HttpGet(intent.getData().toString());
    int result = Activity.RESULT_CANCELED;
    String outPath = intent.getStringExtra(EXTRA_OUTPATH);
    boolean checkMd5 = intent.getBooleanExtra(EXTRA_CHECK_MD5, false);
    int icon = intent.getIntExtra(EXTRA_ICON, 0);
    String title = intent.getStringExtra(EXTRA_TITLE);
    boolean showNotif = (icon > 0 && !TextUtils.isEmpty(title));

    // Build notification
    Builder nb = new Builder(this);
    nb.setWhen(System.currentTimeMillis());
    nb.setContentTitle(title);/*from  ww w  . j  ava2 s.c o  m*/
    nb.setSmallIcon(android.R.drawable.stat_sys_download);
    nb.setOngoing(true);
    Intent i = new Intent(this, SipHome.class);
    nb.setContentIntent(PendingIntent.getActivity(this, 0, i, PendingIntent.FLAG_UPDATE_CURRENT));

    RemoteViews contentView = new RemoteViews(getApplicationContext().getPackageName(),
            R.layout.download_notif);
    contentView.setImageViewResource(R.id.status_icon, icon);
    contentView.setTextViewText(R.id.status_text, getResources().getString(R.string.downloading_text));
    contentView.setProgressBar(R.id.status_progress, 50, 0, false);
    contentView.setViewVisibility(R.id.status_progress_wrapper, View.VISIBLE);
    nb.setContent(contentView);

    final Notification notification = showNotif ? nb.build() : null;
    notification.contentView = contentView;
    if (!TextUtils.isEmpty(outPath)) {
        try {
            File output = new File(outPath);
            if (output.exists()) {
                output.delete();
            }

            if (notification != null) {
                notificationManager.notify(NOTIF_DOWNLOAD, notification);
            }
            ResponseHandler<Boolean> responseHandler = new FileStreamResponseHandler(output, new Progress() {
                private int oldState = 0;

                @Override
                public void run(long progress, long total) {
                    //Log.d(THIS_FILE, "Progress is "+progress+" on "+total);
                    int newState = (int) Math.round(progress * 50.0f / total);
                    if (oldState != newState) {

                        notification.contentView.setProgressBar(R.id.status_progress, 50, newState, false);
                        notificationManager.notify(NOTIF_DOWNLOAD, notification);
                        oldState = newState;
                    }

                }
            });
            boolean hasReply = client.execute(getMethod, responseHandler);

            if (hasReply) {

                if (checkMd5) {
                    URL url = new URL(intent.getData().toString().concat(".md5sum"));
                    InputStream content = (InputStream) url.getContent();
                    if (content != null) {
                        BufferedReader br = new BufferedReader(new InputStreamReader(content));
                        String downloadedMD5 = "";
                        try {
                            downloadedMD5 = br.readLine().split("  ")[0];
                        } catch (NullPointerException e) {
                            throw new IOException("md5_verification : no sum on server");
                        }
                        if (!MD5.checkMD5(downloadedMD5, output)) {
                            throw new IOException("md5_verification : incorrect");
                        }
                    }
                }
                PendingIntent pendingIntent = (PendingIntent) intent
                        .getParcelableExtra(EXTRA_PENDING_FINISH_INTENT);

                try {
                    Runtime.getRuntime().exec("chmod 644 " + outPath);
                } catch (IOException e) {
                    Log.e(THIS_FILE, "Unable to make the apk file readable", e);
                }

                Log.d(THIS_FILE, "Download finished of : " + outPath);
                if (pendingIntent != null) {

                    notification.contentIntent = pendingIntent;
                    notification.flags = Notification.FLAG_AUTO_CANCEL;
                    notification.icon = android.R.drawable.stat_sys_download_done;
                    notification.contentView.setViewVisibility(R.id.status_progress_wrapper, View.GONE);
                    notification.contentView.setTextViewText(R.id.status_text,
                            getResources().getString(R.string.done)
                                    // TODO should be a parameter of this class
                                    + " - Click to install");
                    notificationManager.notify(NOTIF_DOWNLOAD, notification);

                    /*
                    try {
                       pendingIntent.send();
                         notificationManager.cancel(NOTIF_DOWNLOAD);
                    } catch (CanceledException e) {
                       Log.e(THIS_FILE, "Impossible to start pending intent for download finish");
                    }
                    */
                } else {
                    Log.w(THIS_FILE, "Invalid pending intent for finish !!!");
                }

                result = Activity.RESULT_OK;
            }
        } catch (IOException e) {
            Log.e(THIS_FILE, "Exception in download", e);
        }
    }

    if (result == Activity.RESULT_CANCELED) {
        notificationManager.cancel(NOTIF_DOWNLOAD);
    }
}