List of usage examples for android.appwidget AppWidgetManager getInstance
public static AppWidgetManager getInstance(Context context)
From source file:com.atwal.wakeup.battery.util.Utilities.java
/** * Returns a widget with category {@link AppWidgetProviderInfo#WIDGET_CATEGORY_SEARCHBOX} * provided by the same package which is set to be global search activity. * If widgetCategory is not supported, or no such widget is found, returns the first widget * provided by the package./*from ww w . j a v a 2 s . c o m*/ */ @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) public static AppWidgetProviderInfo getSearchWidgetProvider(Context context) { SearchManager searchManager = (SearchManager) context.getSystemService(Context.SEARCH_SERVICE); ComponentName searchComponent = searchManager.getGlobalSearchActivity(); if (searchComponent == null) return null; String providerPkg = searchComponent.getPackageName(); AppWidgetProviderInfo defaultWidgetForSearchPackage = null; AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context); for (AppWidgetProviderInfo info : appWidgetManager.getInstalledProviders()) { if (info.provider.getPackageName().equals(providerPkg)) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { if ((info.widgetCategory & AppWidgetProviderInfo.WIDGET_CATEGORY_SEARCHBOX) != 0) { return info; } else if (defaultWidgetForSearchPackage == null) { defaultWidgetForSearchPackage = info; } } else { return info; } } } return defaultWidgetForSearchPackage; }
From source file:de.ub0r.android.smsdroid.SmsReceiver.java
/** * Update new message {@link Notification}. * * @param context {@link Context}//from ww w.j a v a 2 s. c o m * @param text text of the last assumed unread message * @return number of unread messages */ static int updateNewMessageNotification(final Context context, final String text) { Log.d(TAG, "updNewMsgNoti(", context, ",", text, ")"); final NotificationManager mNotificationMgr = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); final boolean enableNotifications = prefs.getBoolean(PreferencesActivity.PREFS_NOTIFICATION_ENABLE, true); final boolean privateNotification = prefs.getBoolean(PreferencesActivity.PREFS_NOTIFICATION_PRIVACY, false); final boolean showPhoto = !privateNotification && prefs.getBoolean(PreferencesActivity.PREFS_CONTACT_PHOTO, true); if (!enableNotifications) { mNotificationMgr.cancelAll(); Log.d(TAG, "no notification needed!"); } final int[] status = getUnread(context.getContentResolver(), text); final int l = status[ID_COUNT]; final int tid = status[ID_TID]; // FIXME l is always -1.. Log.d(TAG, "l: ", l); if (l < 0) { return l; } if (enableNotifications && (text != null || l == 0)) { mNotificationMgr.cancel(NOTIFICATION_ID_NEW); } Uri uri; PendingIntent pIntent; if (l == 0) { final Intent i = new Intent(context, ConversationListActivity.class); // add pending intent i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); pIntent = PendingIntent.getActivity(context, 0, i, PendingIntent.FLAG_CANCEL_CURRENT); } else { final NotificationCompat.Builder nb = new NotificationCompat.Builder(context); boolean showNotification = true; Intent i; if (tid >= 0) { uri = Uri.parse(MessageListActivity.URI + tid); i = new Intent(Intent.ACTION_VIEW, uri, context, MessageListActivity.class); pIntent = PendingIntent.getActivity(context, 0, i, PendingIntent.FLAG_UPDATE_CURRENT); if (enableNotifications) { final Conversation conv = Conversation.getConversation(context, tid, true); if (conv != null) { String a; if (privateNotification) { if (l == 1) { a = context.getString(R.string.new_message_); } else { a = context.getString(R.string.new_messages_); } } else { a = conv.getContact().getDisplayName(); } showNotification = true; nb.setSmallIcon(PreferencesActivity.getNotificationIcon(context)); nb.setTicker(a); nb.setWhen(lastUnreadDate); if (l == 1) { String body; if (privateNotification) { body = context.getString(R.string.new_message); } else { body = lastUnreadBody; } if (body == null) { body = context.getString(R.string.mms_conversation); } nb.setContentTitle(a); nb.setContentText(body); nb.setContentIntent(pIntent); // add long text nb.setStyle(new NotificationCompat.BigTextStyle().bigText(body)); // add actions Intent nextIntent = new Intent(NotificationBroadcastReceiver.ACTION_MARK_READ); nextIntent.putExtra(NotificationBroadcastReceiver.EXTRA_MURI, uri.toString()); PendingIntent nextPendingIntent = PendingIntent.getBroadcast(context, 0, nextIntent, PendingIntent.FLAG_UPDATE_CURRENT); nb.addAction(R.drawable.ic_menu_mark, context.getString(R.string.mark_read_), nextPendingIntent); nb.addAction(R.drawable.ic_menu_compose, context.getString(R.string.reply), pIntent); } else { nb.setContentTitle(a); nb.setContentText(context.getString(R.string.new_messages, l)); nb.setContentIntent(pIntent); } if (showPhoto // just for the speeeeed && Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { try { conv.getContact().update(context, false, true); } catch (NullPointerException e) { Log.e(TAG, "updating contact failed", e); } Drawable d = conv.getContact().getAvatar(context, null); if (d instanceof BitmapDrawable) { Bitmap bitmap = ((BitmapDrawable) d).getBitmap(); // 24x24 dp according to android iconography -> // http://developer.android.com/design/style/iconography.html#notification int px = Math.round(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 64, context.getResources().getDisplayMetrics())); nb.setLargeIcon(Bitmap.createScaledBitmap(bitmap, px, px, false)); } } } } } else { uri = Uri.parse(MessageListActivity.URI); i = new Intent(Intent.ACTION_VIEW, uri, context, ConversationListActivity.class); pIntent = PendingIntent.getActivity(context, 0, i, PendingIntent.FLAG_UPDATE_CURRENT); if (enableNotifications) { showNotification = true; nb.setSmallIcon(PreferencesActivity.getNotificationIcon(context)); nb.setTicker(context.getString(R.string.new_messages_)); nb.setWhen(lastUnreadDate); nb.setContentTitle(context.getString(R.string.new_messages_)); nb.setContentText(context.getString(R.string.new_messages, l)); nb.setContentIntent(pIntent); nb.setNumber(l); } } // add pending intent i.setFlags(i.getFlags() | Intent.FLAG_ACTIVITY_NEW_TASK); if (enableNotifications && showNotification) { int[] ledFlash = PreferencesActivity.getLEDflash(context); nb.setLights(PreferencesActivity.getLEDcolor(context), ledFlash[0], ledFlash[1]); final SharedPreferences p = PreferenceManager.getDefaultSharedPreferences(context); if (text != null) { final boolean vibrate = p.getBoolean(PreferencesActivity.PREFS_VIBRATE, false); final String s = p.getString(PreferencesActivity.PREFS_SOUND, null); Uri sound; if (s == null || s.length() <= 0) { sound = null; } else { sound = Uri.parse(s); } if (vibrate) { final long[] pattern = PreferencesActivity.getVibratorPattern(context); if (pattern.length == 1 && pattern[0] == 0) { nb.setDefaults(Notification.DEFAULT_VIBRATE); } else { nb.setVibrate(pattern); } } nb.setSound(sound); } } Log.d(TAG, "uri: ", uri); mNotificationMgr.cancel(NOTIFICATION_ID_NEW); if (enableNotifications && showNotification) { try { mNotificationMgr.notify(NOTIFICATION_ID_NEW, nb.getNotification()); } catch (IllegalArgumentException e) { Log.e(TAG, "illegal notification: ", nb, e); } } } Log.d(TAG, "return ", l, " (2)"); //noinspection ConstantConditions AppWidgetManager.getInstance(context).updateAppWidget(new ComponentName(context, WidgetProvider.class), WidgetProvider.getRemoteViews(context, l, pIntent)); return l; }
From source file:org.gaeproxy.GAEProxyService.java
/** Called when the activity is closed. */ @Override//from ww w. j av a 2 s . com public void onDestroy() { EasyTracker.getTracker().trackEvent("service", "stop", getVersionName(), 0L); if (mShutdownReceiver != null) { unregisterReceiver(mShutdownReceiver); mShutdownReceiver = null; } statusLock = true; stopForegroundCompat(1); notifyAlert(getString(R.string.forward_stop), getString(R.string.service_stopped), Notification.FLAG_AUTO_CANCEL); try { if (dnsServer != null) dnsServer.close(); } catch (Exception e) { Log.e(TAG, "DNS Server close unexpected"); } new Thread() { @Override public void run() { // Make sure the connection is closed, important here onDisconnect(); } }.start(); // for widget, maybe exception here try { RemoteViews views = new RemoteViews(getPackageName(), R.layout.gaeproxy_appwidget); views.setImageViewResource(R.id.serviceToggle, R.drawable.off); AppWidgetManager awm = AppWidgetManager.getInstance(this); awm.updateAppWidget(awm.getAppWidgetIds(new ComponentName(this, GAEProxyWidgetProvider.class)), views); } catch (Exception ignore) { // Nothing } Editor ed = settings.edit(); ed.putBoolean("isRunning", false); ed.putBoolean("isConnecting", false); ed.commit(); try { notificationManager.cancel(0); } catch (Exception ignore) { // Nothing } try { ProxySettings.resetProxy(this); } catch (Exception ignore) { // Nothing } super.onDestroy(); statusLock = false; markServiceStopped(); }
From source file:com.daskiworks.ghwatch.backend.UnreadNotificationsService.java
protected void updateWidgets() { if (PreferencesUtils.getBoolean(context, PreferencesUtils.PREF_WIDGET_UNREAD_EXISTS, false)) { AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context); int[] ids = appWidgetManager.getAppWidgetIds(new ComponentName(context, UnreadAppWidgetProvider.class)); Intent intent = new Intent(context, UnreadAppWidgetProvider.class); intent.setAction("android.appwidget.action.APPWIDGET_UPDATE"); intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, ids); context.sendBroadcast(intent);/*from www . j av a 2s . co m*/ Log.d(TAG, "Widget update Intent fired"); } }
From source file:piuk.blockchain.android.WalletApplication.java
public void notifyWidgets() { final Context context = getApplicationContext(); // notify widgets final AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context); for (final AppWidgetProviderInfo providerInfo : appWidgetManager.getInstalledProviders()) { // limit to own widgets if (providerInfo.provider.getPackageName().equals(context.getPackageName())) { final Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_UPDATE); intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, appWidgetManager.getAppWidgetIds(providerInfo.provider)); context.sendBroadcast(intent); }/* w w w . j ava 2s. co m*/ } }
From source file:com.phonemetra.turbo.launcher.AsyncTaskCallback.java
private void preloadWidget(final PendingAddWidgetInfo info) { final AppWidgetProviderInfo pInfo = info.info; final Bundle options = getDefaultOptionsForWidget(mLauncher, info); if (pInfo.configure != null) { info.bindOptions = options;/* w ww .jav a 2 s. co m*/ return; } mWidgetCleanupState = WIDGET_PRELOAD_PENDING; mBindWidgetRunnable = new Runnable() { @Override public void run() { mWidgetLoadingId = mLauncher.getAppWidgetHost().allocateAppWidgetId(); if (options == null) { if (AppWidgetManager.getInstance(mLauncher).bindAppWidgetIdIfAllowed(mWidgetLoadingId, info.componentName)) { mWidgetCleanupState = WIDGET_BOUND; } } else { if (AppWidgetManager.getInstance(mLauncher).bindAppWidgetIdIfAllowed(mWidgetLoadingId, info.componentName, options)) { mWidgetCleanupState = WIDGET_BOUND; } } } }; post(mBindWidgetRunnable); mInflateWidgetRunnable = new Runnable() { @Override public void run() { if (mWidgetCleanupState != WIDGET_BOUND) { return; } AppWidgetHostView hostView = mLauncher.getAppWidgetHost().createView(getContext(), mWidgetLoadingId, pInfo); info.boundWidget = hostView; mWidgetCleanupState = WIDGET_INFLATED; hostView.setVisibility(INVISIBLE); int[] unScaledSize = mLauncher.getWorkspace().estimateItemSize(info.spanX, info.spanY, info, false); // We want the first widget layout to be the correct size. This will be important // for width size reporting to the AppWidgetManager. DragLayer.LayoutParams lp = new DragLayer.LayoutParams(unScaledSize[0], unScaledSize[1]); lp.x = lp.y = 0; lp.customPosition = true; hostView.setLayoutParams(lp); mLauncher.getDragLayer().addView(hostView); } }; post(mInflateWidgetRunnable); }
From source file:com.android.launcher2.AsyncTaskCallback.java
private void preloadWidget(final PendingAddWidgetInfo info) { final AppWidgetProviderInfo pInfo = info.info; final Bundle options = getDefaultOptionsForWidget(mLauncher, info); if (pInfo.configure != null) { info.bindOptions = options;/* w w w . j a va 2 s.co m*/ return; } mWidgetCleanupState = WIDGET_PRELOAD_PENDING; mBindWidgetRunnable = new Runnable() { @Override public void run() { mWidgetLoadingId = mLauncher.getAppWidgetHost().allocateAppWidgetId(); // Options will be null for platforms with JB or lower, so this serves as an // SDK level check. if (options == null) { if (AppWidgetManagerCompat.bindAppWidgetIdIfAllowed(AppWidgetManager.getInstance(mLauncher), mWidgetLoadingId, info.componentName)) { mWidgetCleanupState = WIDGET_BOUND; } } else { if (AppWidgetManagerCompat.bindAppWidgetIdIfAllowed(AppWidgetManager.getInstance(mLauncher), mWidgetLoadingId, info.componentName, options)) { mWidgetCleanupState = WIDGET_BOUND; } } } }; post(mBindWidgetRunnable); mInflateWidgetRunnable = new Runnable() { @Override public void run() { if (mWidgetCleanupState != WIDGET_BOUND) { return; } AppWidgetHostView hostView = mLauncher.getAppWidgetHost().createView(getContext(), mWidgetLoadingId, pInfo); info.boundWidget = hostView; mWidgetCleanupState = WIDGET_INFLATED; hostView.setVisibility(INVISIBLE); int[] unScaledSize = mLauncher.getWorkspace().estimateItemSize(info.spanX, info.spanY, info, false); // We want the first widget layout to be the correct size. This will be important // for width size reporting to the AppWidgetManager. DragLayer.LayoutParams lp = new DragLayer.LayoutParams(unScaledSize[0], unScaledSize[1]); lp.x = lp.y = 0; lp.customPosition = true; hostView.setLayoutParams(lp); mLauncher.getDragLayer().addView(hostView); } }; post(mInflateWidgetRunnable); }
From source file:com.eugene.fithealthmaingit.UI.NavFragments.FragmentJournalMainHome.java
/** * Equation for all of the Nutrition and Meal information *///from ww w. j ava 2 s .c om private void equations() { double mCalorieGoal = Double.valueOf(sharedPreferences.getString(Globals.USER_CALORIES_TO_REACH_GOAL, "")); double mFatGoal = Double.valueOf(sharedPreferences.getString(Globals.USER_DAILY_FAT, "")); double mCarbGoal = Double.valueOf(sharedPreferences.getString(Globals.USER_DAILY_CARBOHYDRATES, "")); double mProteinGoal = Double.valueOf(sharedPreferences.getString(Globals.USER_DAILY_PROTEIN, "")); mCalorieGoalMeal = Double.valueOf(sharedPreferences.getString(Globals.USER_CALORIES_TO_REACH_GOAL, "")) / 4; icSnack = (ImageView) v.findViewById(R.id.icSnack); icBreakfast = (ImageView) v.findViewById(R.id.icBreakfast); icLunch = (ImageView) v.findViewById(R.id.icLunch); icDinner = (ImageView) v.findViewById(R.id.icDinner); // _________________________Calories Snack_____________________________ double mCalConsumedSnack = 0; for (LogMeal logMeal : mLogSnackAdapter.getLogs()) { mCalConsumedSnack += logMeal.getCalorieCount(); } mCalSnack.setText(df.format(mCalConsumedSnack)); // Set icon visible and color based on calories consumed for meal. if (mCalConsumedSnack >= mCalorieGoalMeal + 100) { icSnack.setImageResource(R.mipmap.ic_check_circle); icSnack.setColorFilter(Color.parseColor("#F44336"), android.graphics.PorterDuff.Mode.MULTIPLY); } else if (mCalConsumedSnack > mCalorieGoalMeal - 100 && mCalConsumedSnack < mCalorieGoalMeal + 99) { icSnack.setImageResource(R.mipmap.ic_check_circle); icSnack.setColorFilter(Color.parseColor("#4CAF50"), android.graphics.PorterDuff.Mode.MULTIPLY); } else { icSnack.setImageResource(R.mipmap.ic_check); icSnack.setColorFilter(Color.parseColor("#6D6D6D"), android.graphics.PorterDuff.Mode.MULTIPLY); } // _________________________Calories Breakfast_____________________________ double mCalConsumedBreakfast = 0; for (LogMeal logMeal : mLogBreakfastAdapter.getLogs()) { mCalConsumedBreakfast += logMeal.getCalorieCount(); } mCalBreakfast.setText(df.format(mCalConsumedBreakfast)); // Set icon visible and color based on calories consumed for meal. if (mCalConsumedBreakfast >= mCalorieGoalMeal + 100) { icBreakfast.setColorFilter(Color.parseColor("#F44336"), android.graphics.PorterDuff.Mode.MULTIPLY); icBreakfast.setImageResource(R.mipmap.ic_check_circle); } else if (mCalConsumedBreakfast > mCalorieGoalMeal - 100 && mCalConsumedBreakfast < mCalorieGoalMeal + 99) { icBreakfast.setColorFilter(Color.parseColor("#4CAF50"), android.graphics.PorterDuff.Mode.MULTIPLY); icBreakfast.setImageResource(R.mipmap.ic_check_circle); } else { icBreakfast.setImageResource(R.mipmap.ic_check); icBreakfast.setColorFilter(Color.parseColor("#6D6D6D"), android.graphics.PorterDuff.Mode.MULTIPLY); } // _________________________Calories Lunch_____________________________ double mCalConsumedLunch = 0; for (LogMeal logMeal : mLogLunchAdapter.getLogs()) { mCalConsumedLunch += logMeal.getCalorieCount(); } mCalLunch.setText(df.format(mCalConsumedLunch)); // Set icon visible and color based on calories consumed for meal. if (mCalConsumedLunch >= mCalorieGoalMeal + 100) { icLunch.setImageResource(R.mipmap.ic_check_circle); icLunch.setColorFilter(Color.parseColor("#F44336"), android.graphics.PorterDuff.Mode.MULTIPLY); } else if (mCalConsumedLunch > mCalorieGoalMeal - 100 && mCalConsumedLunch < mCalorieGoalMeal + 99) { icLunch.setImageResource(R.mipmap.ic_check_circle); icLunch.setColorFilter(Color.parseColor("#4CAF50"), android.graphics.PorterDuff.Mode.MULTIPLY); } else { icLunch.setImageResource(R.mipmap.ic_check); icLunch.setColorFilter(Color.parseColor("#6D6D6D"), android.graphics.PorterDuff.Mode.MULTIPLY); } // _________________________Calories Lunch_____________________________ double mCalConsumedDinner = 0; for (LogMeal logMeal : mLogDinnerAdapter.getLogs()) { mCalConsumedDinner += logMeal.getCalorieCount(); } mCalDinner.setText(df.format(mCalConsumedDinner)); // Set icon visible and color based on calories consumed for meal. if (mCalConsumedDinner >= mCalorieGoalMeal + 100) { icDinner.setImageResource(R.mipmap.ic_check_circle); icDinner.setColorFilter(Color.parseColor("#F44336"), android.graphics.PorterDuff.Mode.MULTIPLY); } else if (mCalConsumedDinner > mCalorieGoalMeal - 100 && mCalConsumedDinner < mCalorieGoalMeal + 99) { icDinner.setImageResource(R.mipmap.ic_check_circle); icDinner.setColorFilter(Color.parseColor("#4CAF50"), android.graphics.PorterDuff.Mode.MULTIPLY); } else { icDinner.setImageResource(R.mipmap.ic_check); icDinner.setColorFilter(Color.parseColor("#6D6D6D"), android.graphics.PorterDuff.Mode.MULTIPLY); } // _________________________Calories, Fat, Carbs, Protein All_____________________________ // Nutrition Consumed double mAllCaloriesConsumed = 0; double mAllFatConsumed = 0; double mAllCarbsConsumed = 0; double mAllProteinConsumed = 0; for (LogMeal logMeal : mLogAdapterAll.getLogs()) { mAllCaloriesConsumed += logMeal.getCalorieCount(); mAllFatConsumed += logMeal.getFatCount(); mAllCarbsConsumed += logMeal.getCarbCount(); mAllProteinConsumed += logMeal.getProteinCount(); } // Nutrition Goals // Remainder Nutrition mCaloriesRemainder.setText(df.format(mCalorieGoal - mAllCaloriesConsumed) + " Left"); mFatRemainder.setText(df.format(mFatGoal - mAllFatConsumed) + " Left"); mCarbRemainder.setText(df.format(mCarbGoal - mAllCarbsConsumed) + " Left"); mProteinRemainder.setText(df.format(mProteinGoal - mAllProteinConsumed) + " Left"); // Progress bars mPbCalories.setMax(Integer.valueOf(df.format(mCalorieGoal))); mPbCalories.setProgress(Integer.valueOf(df.format(mAllCaloriesConsumed))); mPbFat.setMax(Integer.valueOf(df.format(mFatGoal))); mPbFat.setProgress(Integer.valueOf(df.format(mAllFatConsumed))); mPbCarbs.setMax(Integer.valueOf(df.format(mCarbGoal))); mPbCarbs.setProgress(Integer.valueOf(df.format(mAllCarbsConsumed))); mPbProtein.setMax(Integer.valueOf(df.format(mProteinGoal))); mPbProtein.setProgress(Integer.valueOf(df.format(mAllProteinConsumed))); /** * Update Widget */ Context context = getActivity(); AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context); if (appWidgetManager != null) { RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.new_app_widget); ComponentName thisWidget = new ComponentName(context, FitHealthWidget.class); views.setProgressBar(R.id.pbCal, Integer.valueOf(df.format(mCalorieGoal)), Integer.valueOf(df.format(mAllCaloriesConsumed)), false); views.setProgressBar(R.id.pbFat, Integer.valueOf(df.format(mFatGoal)), Integer.valueOf(df.format(mAllFatConsumed)), false); views.setProgressBar(R.id.pbCarb, Integer.valueOf(df.format(mCarbGoal)), Integer.valueOf(df.format(mAllCarbsConsumed)), false); views.setProgressBar(R.id.pbPro, Integer.valueOf(df.format(mProteinGoal)), Integer.valueOf(df.format(mAllProteinConsumed)), false); views.setTextViewText(R.id.txtRemainderCal, df.format(mCalorieGoal - mAllCaloriesConsumed)); views.setTextViewText(R.id.txtRemainderFat, df.format(mFatGoal - mAllFatConsumed)); views.setTextViewText(R.id.txtRemainderCarb, df.format(mCarbGoal - mAllCarbsConsumed)); views.setTextViewText(R.id.txtRemainderPro, df.format(mProteinGoal - mAllProteinConsumed)); appWidgetManager.updateAppWidget(thisWidget, views); } }
From source file:de.schildbach.wallet.service.BlockchainServiceImpl.java
public void notifyWidgets() { final AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(this); final ComponentName providerName = new ComponentName(this, WalletBalanceWidgetProvider.class); final int[] appWidgetIds = appWidgetManager.getAppWidgetIds(providerName); if (appWidgetIds.length > 0) { final Wallet wallet = application.getWallet(); final BigInteger balance = wallet.getBalance(BalanceType.ESTIMATED); WalletBalanceWidgetProvider.updateWidgets(this, appWidgetManager, appWidgetIds, balance); }//from ww w . j a v a 2 s . co m }
From source file:de.schildbach.wallet.worldcoin.service.BlockchainServiceImpl.java
public void notifyWidgets() { final AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(this); final ComponentName providerName = new ComponentName(this, WalletBalanceWidgetProvider.class); final int[] appWidgetIds; try {//from www .j a v a 2 s .c om appWidgetIds = appWidgetManager.getAppWidgetIds(providerName); } catch (RuntimeException e) { // Bug #6 - App server dead? Log.e("worldcoin", "App server appears dead - Runtime Exception when running getAppWidgetIds. Returning.."); return; } if (appWidgetIds.length > 0) { final Wallet wallet = application.getWallet(); final BigInteger balance = wallet.getBalance(BalanceType.ESTIMATED); WalletBalanceWidgetProvider.updateWidgets(this, appWidgetManager, appWidgetIds, balance); } }