Java Code Examples for android.widget.RemoteViews#setProgressBar()

The following examples show how to use android.widget.RemoteViews#setProgressBar() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UpdateFragment.java    From YCUpdateApp with Apache License 2.0 6 votes vote down vote up
protected void setNotification(int progress) {
    if (mActivity==null){
        return;
    }
    Intent intent = new Intent();
    PendingIntent pendingIntent = PendingIntent.getActivity(mActivity, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
    RemoteViews remoteViews = new RemoteViews(mActivity.getPackageName(), R.layout.remote_notification_view);
    remoteViews.setTextViewText(R.id.tvTitle, getResources().getString(R.string.app_name));
    remoteViews.setProgressBar(R.id.pb, 100, progress, false);
    NotificationUtils notificationUtils = new NotificationUtils(mActivity);
    NotificationManager manager = notificationUtils.getManager();
    Notification notification = notificationUtils.setContentIntent(pendingIntent)
            .setContent(remoteViews)
            .setFlags(Notification.FLAG_AUTO_CANCEL)
            .setOnlyAlertOnce(true)
            .getNotification("来了一条消息", "下载apk", R.mipmap.ic_launcher);
    //下载成功或者失败
    if (progress == 100 || progress == -1) {
        notificationUtils.clearNotification();
    } else {
        manager.notify(1, notification);
    }
}
 
Example 2
Source File: UpdateService.java    From Fishing with GNU General Public License v3.0 6 votes vote down vote up
public void createNotification(String title) {
	notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
	notification = new Notification();

	contentView = new RemoteViews(getPackageName(),
			R.layout.setting_update_notification);
	contentView.setTextViewText(R.id.notificationTitle, title);
	contentView.setTextViewText(R.id.notificationPercent, "0%");
	contentView.setProgressBar(R.id.notificationProgress, 100, 0, false);

	notification.contentView = contentView;
	notification.icon = R.mipmap.logo;
	
	Intent stopIntent = new Intent(this, UpdateService.class);
	PendingIntent pendingIntent = PendingIntent.getService(this, 0, stopIntent, 0);
	
	notification.deleteIntent = pendingIntent;
	notificationManager.notify(notification_id, notification);

}
 
Example 3
Source File: OverclockingWidgetView.java    From rpicheck with MIT License 6 votes vote down vote up
public static RemoteViews initDefaultView(Context context, int appWidgetId, RaspberryDeviceBean deviceBean, boolean showTemp, boolean showArm, boolean showLoad, boolean showMemory) {
    LOGGER.debug("Initiating default view for Widget[ID={}].", appWidgetId);
    final AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
    final RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.overclocking_widget);
    views.setOnClickPendingIntent(R.id.buttonRefresh, getSelfPendingIntent(context, appWidgetId, ACTION_WIDGET_UPDATE_ONE_MANUAL));
    PendingIntent activityIntent = getActivityIntent(context);
    views.setOnClickPendingIntent(R.id.linLayoutName, activityIntent);
    views.setOnClickPendingIntent(R.id.linLayoutTemp, activityIntent);
    views.setOnClickPendingIntent(R.id.linLayoutArm, activityIntent);
    views.setOnClickPendingIntent(R.id.linLayoutLoad, activityIntent);
    views.setOnClickPendingIntent(R.id.linLayoutMem, activityIntent);
    views.setTextViewText(R.id.textDeviceValue, deviceBean.getName());
    views.setTextViewText(R.id.textDeviceUserHost, String.format("%s@%s", deviceBean.getUser(), deviceBean.getHost()));
    views.setViewVisibility(R.id.linLayoutTemp, showTemp ? View.VISIBLE : View.GONE);
    views.setViewVisibility(R.id.linLayoutArm, showArm ? View.VISIBLE : View.GONE);
    views.setViewVisibility(R.id.linLayoutLoad, showLoad ? View.VISIBLE : View.GONE);
    views.setViewVisibility(R.id.linLayoutMem, showMemory ? View.VISIBLE : View.GONE);
    views.setProgressBar(R.id.progressBarArmValue, 100, 0, false);
    views.setProgressBar(R.id.progressBarLoad, 100, 0, false);
    views.setProgressBar(R.id.progressBarMemory, 100, 0, false);
    views.setProgressBar(R.id.progressBarTempValue, 100, 0, false);
    appWidgetManager.updateAppWidget(appWidgetId, views);
    return views;
}
 
Example 4
Source File: ApkDownloadAsyncTask.java    From letv with Apache License 2.0 5 votes vote down vote up
protected void onPreExecute() {
    super.onPreExecute();
    PendingIntent pendingIntent = PendingIntent.getActivity(this.mContext, 0, new Intent(), 0);
    this.notification.icon = R.drawable.notification_icon;
    this.notification.tickerText = this.mContext.getString(R.string.update_asynctask_downloading);
    this.notification.flags = 16;
    RemoteViews remoteViews = new RemoteViews(this.mContext.getPackageName(), R.layout.notification_updata_layout);
    remoteViews.setTextViewText(R.id.app_name, this.apkNameCn);
    remoteViews.setTextViewText(R.id.progress_text, "0%");
    remoteViews.setProgressBar(R.id.progress_value, 100, 0, false);
    this.notification.contentView = remoteViews;
    notificationManager.notify(this.notificationId, this.notification);
}
 
Example 5
Source File: ApkDownloadAsyncTask.java    From letv with Apache License 2.0 5 votes vote down vote up
protected void onPreExecute() {
    super.onPreExecute();
    PendingIntent pendingIntent = PendingIntent.getActivity(this.activity, 0, new Intent(), 0);
    this.notification.icon = R.anim.notification_download;
    this.notification.tickerText = BaseApplication.getInstance().getString(R.string.update_asynctask_downloading);
    this.notification.flags = 16;
    RemoteViews remoteViews = new RemoteViews(this.activity.getPackageName(), R.layout.notification_updata_layout);
    remoteViews.setTextViewText(R.id.app_name, this.activity.getString(R.string.unknown_apk) + this.apkNameCn);
    remoteViews.setTextViewText(R.id.progress_text, "0%");
    remoteViews.setProgressBar(R.id.progress_value, 100, 0, false);
    this.notification.contentView = remoteViews;
    this.notification.contentIntent = pendingIntent;
    notificationManager.notify(this.notificationId, this.notification);
}
 
Example 6
Source File: NotificationActivity.java    From AndroidSamples with Apache License 2.0 5 votes vote down vote up
public void updateCustom(int notificationId, int progress) {
    NotificationCompat.Builder builder = mMap.get(notificationId);
    if (null != builder) {
        // 修改进度条
        @SuppressLint("RestrictedApi")
        RemoteViews contentView = builder.getContentView();
        contentView.setProgressBar(R.id.pBar, 100, progress, false);
        builder.setCustomContentView(contentView);
        mManager.notify(notificationId, builder.build());
    }
}
 
Example 7
Source File: DownloadingService.java    From ESeal with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
public void createNotification() {
    notification = new Notification(
            getApplicationInfo().icon,
            "安装包正在下载...",
            System.currentTimeMillis());
    notification.flags = Notification.FLAG_ONGOING_EVENT;
    /*** 自定义  Notification 的显示****/
    contentView = new RemoteViews(getPackageName(), ResourceUtils.getResourceIdByName(mContext, "layout", "jjdxm_download_notification"));
    contentView.setTextViewText(ResourceUtils.getResourceIdByName(mContext, "id", "jjdxm_update_title"), getApplicationInfo().name);
    contentView.setProgressBar(ResourceUtils.getResourceIdByName(mContext, "id", "jjdxm_update_progress_bar"), 100, 0, false);
    contentView.setTextViewText(ResourceUtils.getResourceIdByName(mContext, "id", "jjdxm_update_progress_text"), "0%");

    /**暂停和开始*/
    Intent downIntent = new Intent(this, DownloadingService.class);
    downIntent.putExtra(UpdateConstants.DATA_ACTION, UpdateConstants.PAUSE_DOWN);
    downIntent.putExtra("update", update);
    PendingIntent pendingIntent1 = PendingIntent.getService(this, UpdateConstants.PAUSE_DOWN, downIntent, PendingIntent.FLAG_UPDATE_CURRENT);
    contentView.setOnClickPendingIntent(ResourceUtils.getResourceIdByName(mContext, "id", "jjdxm_update_rich_notification_continue"), pendingIntent1);

    /**取消*/
    Intent cancelIntent = new Intent(this, DownloadingService.class);
    cancelIntent.putExtra(UpdateConstants.DATA_ACTION, UpdateConstants.CANCEL_DOWN);
    cancelIntent.putExtra("update", update);
    PendingIntent pendingIntent2 = PendingIntent.getService(this, UpdateConstants.CANCEL_DOWN, cancelIntent, PendingIntent.FLAG_CANCEL_CURRENT);
    contentView.setOnClickPendingIntent(ResourceUtils.getResourceIdByName(mContext, "id", "jjdxm_update_rich_notification_cancel"), pendingIntent2);

    notification.contentView = contentView;
    notification.flags = Notification.FLAG_AUTO_CANCEL;
    notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

    notificationManager.notify(UpdateConstants.NOTIFICATION_ACTION, notification);
}
 
Example 8
Source File: DownloadService.java    From android-project-wo2b with Apache License 2.0 5 votes vote down vote up
/**
 * 下载完成, 发送下载完成的广播
 */
private void notifyDownloadCompleted(final Context context, final Request request, final File file)
{
	// 取消旧上一个通知
	int preNotificationId = request.mNotificationId;
	mNotificationManager.cancel(preNotificationId);

	RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.api_download_notification_ok);
	remoteViews.setImageViewResource(R.id.noti_icon, R.drawable.notification_icon);
	remoteViews.setTextViewText(R.id.noti_file_name, request.mTitle);
	remoteViews.setTextViewText(R.id.noti_progressBarLeft, context.getString(R.string.api_download_ok));
	remoteViews.setTextViewText(R.id.noti_progressBarRight, PROGRESSBAR_MAX + "%");
	remoteViews.setProgressBar(R.id.noti_progressBar, PROGRESSBAR_MAX, PROGRESSBAR_MAX, false);

	// 消息信息设置
	Notification notification = new Notification();
	notification.tickerText = request.mTitle;
	notification.icon = R.drawable.notification_icon;
	notification.contentView = remoteViews;
	notification.flags = Notification.FLAG_AUTO_CANCEL;

	// 点击通知栏
	String extName = FileUtils.getFileExtension(file.getName());
	Intent intent = new Intent();
	if ("apk".equalsIgnoreCase(extName))
	{
		intent.setAction(Intent.ACTION_VIEW);
		intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
		intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive");
	}
	else
	{
		intent.setAction("com.wo2b.download.AActivity");
	}
	notification.contentIntent = PendingIntent.getActivity(context, 1, intent, PendingIntent.FLAG_CANCEL_CURRENT);

	mNotificationManager.notify(preNotificationId, notification);
}
 
Example 9
Source File: V3CustomNotification.java    From travelguide with Apache License 2.0 5 votes vote down vote up
@Override
public Notification updateNotification(Context c) {
    Notification n = mNotification;

    n.icon = mIcon;

    n.flags |= Notification.FLAG_ONGOING_EVENT;

    if (android.os.Build.VERSION.SDK_INT > 10) {
        n.flags |= Notification.FLAG_ONLY_ALERT_ONCE; // only matters for
                                                      // Honeycomb
    }

    // Build the RemoteView object
    RemoteViews expandedView = new RemoteViews(
            c.getPackageName(),
            R.layout.status_bar_ongoing_event_progress_bar);

    expandedView.setTextViewText(R.id.title, mTitle);
    // look at strings
    expandedView.setViewVisibility(R.id.description, View.VISIBLE);
    expandedView.setTextViewText(R.id.description,
            Helpers.getDownloadProgressString(mCurrentBytes, mTotalBytes));
    expandedView.setViewVisibility(R.id.progress_bar_frame, View.VISIBLE);
    expandedView.setProgressBar(R.id.progress_bar,
            (int) (mTotalBytes >> 8),
            (int) (mCurrentBytes >> 8),
            mTotalBytes <= 0);
    expandedView.setViewVisibility(R.id.time_remaining, View.VISIBLE);
    expandedView.setTextViewText(
            R.id.time_remaining,
            c.getString(R.string.time_remaining_notification,
                    Helpers.getTimeRemaining(mTimeRemaining)));
    expandedView.setTextViewText(R.id.progress_text,
            Helpers.getDownloadProgressPercent(mCurrentBytes, mTotalBytes));
    expandedView.setImageViewResource(R.id.appIcon, mIcon);
    n.contentView = expandedView;
    n.contentIntent = mPendingIntent;
    return n;
}
 
Example 10
Source File: V3CustomNotification.java    From Alite with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Notification updateNotification(Context c) {
    Notification n = mNotification;

    n.icon = mIcon;

    n.flags |= Notification.FLAG_ONGOING_EVENT;

    if (android.os.Build.VERSION.SDK_INT > 10) {
        n.flags |= Notification.FLAG_ONLY_ALERT_ONCE; // only matters for
                                                      // Honeycomb
    }

    // Build the RemoteView object
    RemoteViews expandedView = new RemoteViews(
            c.getPackageName(),
            R.layout.status_bar_ongoing_event_progress_bar);

    expandedView.setTextViewText(R.id.title, mTitle);
    // look at strings
    expandedView.setViewVisibility(R.id.description, View.VISIBLE);
    expandedView.setTextViewText(R.id.description,
            Helpers.getDownloadProgressString(mCurrentBytes, mTotalBytes));
    expandedView.setViewVisibility(R.id.progress_bar_frame, View.VISIBLE);
    expandedView.setProgressBar(R.id.progress_bar,
            (int) (mTotalBytes >> 8),
            (int) (mCurrentBytes >> 8),
            mTotalBytes <= 0);
    expandedView.setViewVisibility(R.id.time_remaining, View.VISIBLE);
    expandedView.setTextViewText(
            R.id.time_remaining,
            c.getString(R.string.time_remaining_notification,
                    Helpers.getTimeRemaining(mTimeRemaining)));
    expandedView.setTextViewText(R.id.progress_text,
            Helpers.getDownloadProgressPercent(mCurrentBytes, mTotalBytes));
    expandedView.setImageViewResource(R.id.appIcon, mIcon);
    n.contentView = expandedView;
    n.contentIntent = mPendingIntent;
    return n;
}
 
Example 11
Source File: UpdateManager.java    From quickmark with MIT License 5 votes vote down vote up
/**
 * ����������createNotification����
 * 
 * @param
 * @return
 * @see UpdateService
 */
@SuppressWarnings("deprecation")
public void createNotification() {

	String app_name = null;
	// notification = new Notification(R.drawable.dot_enable,app_name +
	// getString(R.string.is_downing) ,System.currentTimeMillis());
	notification = new Notification(
	// R.drawable.video_player,//Ӧ�õ�ͼ��
			R.drawable.ic_launcher,// Ӧ�õ�ͼ��
			mHashMap.get("name") + "��������", System.currentTimeMillis());
	notification.flags = Notification.FLAG_ONGOING_EVENT;

	contentView = new RemoteViews(mContext.getPackageName(),
			R.layout.notification_item);
	contentView.setTextViewText(R.id.notificationTitle,
			mHashMap.get("name") + "��������");
	contentView.setTextViewText(R.id.notificationPercent, "������");
	contentView.setProgressBar(R.id.notificationProgress, 100, 0, false);
	notification.contentView = contentView;

	// updateIntent = new Intent(this, AboutActivity.class);
	// updateIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
	// //updateIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
	// pendingIntent = PendingIntent.getActivity(this, 0, updateIntent, 0);
	// notification.contentIntent = pendingIntent;

	notificationManager = (NotificationManager) mContext
			.getSystemService(Context.NOTIFICATION_SERVICE);
	notificationManager.notify(R.layout.notification_item, notification);
}
 
Example 12
Source File: WidgetUpdateTask.java    From rpicheck with MIT License 5 votes vote down vote up
private void updateProgressbar(RemoteViews views, int progressBarId, double min, double max, double value) {
    if (value > max) {
        value = max;
    } else if (value < min) {
        value = min;
    }
    double scaledValue = ((value - min) / (max - min)) * 100;
    LOGGER.debug("Updating progressbar[id={}]: scaledValue = {}", progressBarId, scaledValue);
    views.setProgressBar(progressBarId, 100, (int) scaledValue, false);
}
 
Example 13
Source File: CallNotification.java    From codeexamples-android with Eclipse Public License 1.0 5 votes vote down vote up
public void createNotification() {

		NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);

		for (int i = 0; i <= 10; i++) {

			Notification notification = new Notification(R.drawable.icon,
					"A new notification", System.currentTimeMillis());
			// Wir setzen das Flag, dass sie Notification nach Selektion
			// verschwindet
			notification.flags |= Notification.FLAG_AUTO_CANCEL;

			RemoteViews view = new RemoteViews(getPackageName(), R.layout.main);
			int done = i * 10;
			view.setProgressBar(R.id.progressBar1, 100, done, false);
			view.setTextViewText(R.id.textView1,
					"Das ist die Nachricht. Wir sind " + done + " % fertig");
			notification.contentView = view;

			Intent intent = new Intent(this, TargetActivity.class);
			PendingIntent pendingIntent = PendingIntent.getActivity(this, 0,
					intent, PendingIntent.FLAG_CANCEL_CURRENT);
			notification.contentIntent = pendingIntent;
			notificationManager.notify(0, notification);

			// Wir simulieren mal eine lange Aktion
			try {
				Thread.sleep(1000);
			} catch (InterruptedException e) {
			}
		}
	}
 
Example 14
Source File: DownloadService.java    From fanfouapp-opensource with Apache License 2.0 5 votes vote down vote up
private void showProgress() {
    this.notification = new Notification(R.drawable.ic_notify_download,
            "正在下载饭否客户端", System.currentTimeMillis());
    this.notification.flags |= Notification.FLAG_ONGOING_EVENT;
    this.notification.flags |= Notification.FLAG_AUTO_CANCEL;
    this.notification.contentIntent = PendingIntent.getActivity(this, 0,
            new Intent(), 0);
    final RemoteViews view = new RemoteViews(getPackageName(),
            R.layout.download_notification);
    view.setTextViewText(R.id.download_notification_text, "正在下载饭否客户端 0%");
    view.setProgressBar(R.id.download_notification_progress, 100, 0, false);
    this.notification.contentView = view;
    this.nm.notify(DownloadService.NOTIFICATION_PROGRESS_ID,
            this.notification);
}
 
Example 15
Source File: DownloadService.java    From android-project-wo2b with Apache License 2.0 4 votes vote down vote up
/**
 * 开始下载
 * 
 * @param context
 * @param title
 * @param icon
 */
private void notifyDownloadStart(Context context, Request request)
{
	RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.api_download_notification);
	remoteViews.setProgressBar(R.id.noti_progressBar, PROGRESSBAR_MAX, 0, false);
	remoteViews.setImageViewResource(R.id.noti_icon, R.drawable.notification_remote_icon);
	remoteViews.setTextViewText(R.id.noti_file_name, request.mTitle);
	
	String host = CommonUtils.getHost(request.mDownloadUrl);
	if (CommonUtils.isWo2bHost(request.mDownloadUrl))
	{
		remoteViews.setTextViewText(R.id.noti_progressBarLeft, "www.wo2b.com");
	}
	else
	{
		remoteViews.setTextViewText(R.id.noti_progressBarLeft, host);
	}
	
	
	// 执行取消操作的PendingIntent, 向DownloadService发起取消下载的命令
	Intent cancelIntent = new Intent();
	cancelIntent.setClass(context, DownloadService.class);
	cancelIntent.putExtra(DownloadService.EXTRA_EVENT_TYPE, DownloadService.EVENT_CANCEL);
	cancelIntent.putExtra(DownloadService.EXTRA_DOWNLOAD_URL, request.mDownloadUrl);

	PendingIntent cancelPendingIntent = PendingIntent.getService(context, 100, cancelIntent,
			PendingIntent.FLAG_CANCEL_CURRENT);
	remoteViews.setOnClickPendingIntent(R.id.noti_cancel, cancelPendingIntent);
	
	// 消息信息设置
	Notification notification = new Notification();
	notification.tickerText = request.mTitle;
	notification.icon = R.drawable.notification_icon;
	notification.contentView = remoteViews;
	// notification.flags = Notification.FLAG_AUTO_CANCEL;
	notification.flags = Notification.FLAG_ONGOING_EVENT;

	// 点击通知栏
	Intent intent = new Intent();
	intent.setAction("com.wo2b.download.AActivity");
	// intent.setClass(context, Download.class);

	notification.contentIntent = PendingIntent.getActivity(context, 1, intent, PendingIntent.FLAG_CANCEL_CURRENT);
	
	// 生成通知ID
	int notificationId = new Random().nextInt(10000);

	mNotificationManager.notify(notificationId, notification);
	
	request.mNotification = notification;
	request.mNotificationId = notificationId;

}
 
Example 16
Source File: TodayWidgetProvider.java    From ETSMobile-Android2 with Apache License 2.0 4 votes vote down vote up
private void updateAppWidget(Context context, AppWidgetManager appWidgetManager,
                             int appWidgetId) {
    RemoteViews views = new RemoteViews(context.getPackageName(), widgetInitialLayoutId);

    if (!syncEnCours && mUserLoggedIn) {
        views.setViewVisibility(syncBtnId, View.VISIBLE);
        views.setViewVisibility(progressBarId, View.GONE);
    } else if (syncEnCours && mUserLoggedIn) {
        views.setViewVisibility(progressBarId, View.VISIBLE);
        views.setProgressBar(progressBarId, 0, 0, true);
        views.setViewVisibility(syncBtnId, View.GONE);
    }

    int bgColor = TodayWidgetConfigureActivity.loadBgColorPref(context, appWidgetId);
    int textColor = TodayWidgetConfigureActivity.loadTextColorPref(context, appWidgetId);
    int bgOpacity = TodayWidgetConfigureActivity.loadOpacityPref(context, appWidgetId);

    // Vue affichée lorsque la liste est vide
    views.setTextColor(emptyViewId, textColor);
    views.setEmptyView(todayListId, emptyViewId);

    if (mUserLoggedIn) {
        views.setTextColor(todayNameTvId, textColor);
        Intent intent = new Intent(context, TodayWidgetService.class);
        intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
        intent.putExtra(Constants.TEXT_COLOR, textColor);
        intent.putExtra(Constants.DATE, dateTime.getMillis());
        intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));
        views.setTextViewText(emptyViewId, context.getString(R.string.no_classes_widget));
        views.setRemoteAdapter(appWidgetId, todayListId, intent);
        appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetId, todayListId);
        views.setViewVisibility(emptyViewId, View.VISIBLE);
        views.setViewVisibility(prevDayBtnId, View.VISIBLE);
        views.setViewVisibility(nextDayBtnId, View.VISIBLE);
        setUpSyncBtn(views, textColor);
        setUpPrevBtn(views, textColor);
        setUpNextBtn(views, textColor);
    } else {
        views.setViewVisibility(syncBtnId, View.GONE);
        views.setViewVisibility(progressBarId, View.GONE);
        views.setViewVisibility(todayListId, View.GONE);
        views.setViewVisibility(emptyViewId, View.GONE);
        views.setViewVisibility(prevDayBtnId, View.GONE);
        views.setViewVisibility(nextDayBtnId, View.GONE);
    }

    setUpTodayDateTv(context, views);
    setUpLoginBtn(context, views, textColor);

    bgColor = ColorUtils.setAlphaComponent(bgColor, bgOpacity);
    views.setInt(widgetLayoutId, "setBackgroundColor", bgColor);

    // Instruct the widget manager to update the widget
    appWidgetManager.updateAppWidget(appWidgetId, views);
}