Search in sources :

Example 46 with AppWidgetManager

use of android.appwidget.AppWidgetManager in project Fairphone by Kwamecorp.

the class PeaceOfMindBroadCastReceiver method updateWidget.

private void updateWidget(Context context) {
    AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
    int[] appWidgetIds = appWidgetManager.getAppWidgetIds(new ComponentName(context, WidgetProvider.class));
    if (appWidgetIds.length > 0) {
        new WidgetProvider().onUpdate(context, appWidgetManager, appWidgetIds);
    }
}
Also used : WidgetProvider(org.fairphone.peaceofmind.widget.WidgetProvider) AppWidgetManager(android.appwidget.AppWidgetManager) ComponentName(android.content.ComponentName)

Example 47 with AppWidgetManager

use of android.appwidget.AppWidgetManager in project Etar-Calendar by Etar-Group.

the class CalendarAppWidgetProvider method onReceive.

/**
     * {@inheritDoc}
     */
@Override
public void onReceive(Context context, Intent intent) {
    // Handle calendar-specific updates ourselves because they might be
    // coming in without extras, which AppWidgetProvider then blocks.
    final String action = intent.getAction();
    if (LOGD)
        Log.d(TAG, "AppWidgetProvider got the intent: " + intent.toString());
    if (Utils.getWidgetUpdateAction(context).equals(action)) {
        AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
        performUpdate(context, appWidgetManager, appWidgetManager.getAppWidgetIds(getComponentName(context)), null);
    } else if (action.equals(Intent.ACTION_PROVIDER_CHANGED) || action.equals(Intent.ACTION_TIME_CHANGED) || action.equals(Intent.ACTION_TIMEZONE_CHANGED) || action.equals(Intent.ACTION_DATE_CHANGED) || action.equals(Utils.getWidgetScheduledUpdateAction(context))) {
        Intent service = new Intent(context, CalendarAppWidgetService.class);
        context.startService(service);
    } else {
        super.onReceive(context, intent);
    }
}
Also used : AppWidgetManager(android.appwidget.AppWidgetManager) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent)

Example 48 with AppWidgetManager

use of android.appwidget.AppWidgetManager in project android_frameworks_base by DirtyUnicorns.

the class TestAppWidgetProvider method onReceive.

public void onReceive(Context context, Intent intent) {
    String action = intent.getAction();
    Log.d(TAG, "intent=" + intent);
    if (AppWidgetManager.ACTION_APPWIDGET_ENABLED.equals(action)) {
        Log.d(TAG, "ENABLED");
    } else if (AppWidgetManager.ACTION_APPWIDGET_DISABLED.equals(action)) {
        Log.d(TAG, "DISABLED");
    } else if (AppWidgetManager.ACTION_APPWIDGET_UPDATE.equals(action)) {
        if (true)
            return;
        Log.d(TAG, "UPDATE");
        Bundle extras = intent.getExtras();
        int[] appWidgetIds = extras.getIntArray(AppWidgetManager.EXTRA_APPWIDGET_IDS);
        AppWidgetManager gm = AppWidgetManager.getInstance(context);
        RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.test_appwidget);
        views.setTextViewText(R.id.oh_hai_text, "hai: " + SystemClock.elapsedRealtime());
        if (false) {
            gm.updateAppWidget(appWidgetIds, views);
        } else {
            gm.updateAppWidget(new ComponentName("com.android.tests.appwidgetprovider", "com.android.tests.appwidgetprovider.TestAppWidgetProvider"), views);
        }
    }
}
Also used : RemoteViews(android.widget.RemoteViews) Bundle(android.os.Bundle) AppWidgetManager(android.appwidget.AppWidgetManager) ComponentName(android.content.ComponentName)

Example 49 with AppWidgetManager

use of android.appwidget.AppWidgetManager in project WordPress-Android by wordpress-mobile.

the class StatsWidgetProvider method refreshAllWidgets.

public static void refreshAllWidgets(Context context, SiteStore siteStore) {
    AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
    ComponentName thisWidget = new ComponentName(context, StatsWidgetProvider.class);
    int[] allWidgetIds = appWidgetManager.getAppWidgetIds(thisWidget);
    refreshWidgets(context, allWidgetIds, siteStore);
}
Also used : AppWidgetManager(android.appwidget.AppWidgetManager) ComponentName(android.content.ComponentName)

Example 50 with AppWidgetManager

use of android.appwidget.AppWidgetManager in project newsrob by marianokamp.

the class UnreadWidgetProvider method requestWidgetsUpdate.

public static void requestWidgetsUpdate(Context ctx) {
    AppWidgetManager awm = AppWidgetManager.getInstance(ctx);
    int[] appWidgetIds = awm.getAppWidgetIds(new ComponentName(ctx, UnreadWidgetProvider.class));
    Timing t = new Timing(TAG + " requestWidgetsUpdate for " + appWidgetIds.length + " widget(s)", ctx);
    for (int appWidgetId : appWidgetIds) {
        PL.log("UnreadWidgetProvider.requestWidgetsUpdate, about to call UWP.buildUpdate for widget id " + appWidgetId + ".", ctx);
        awm.updateAppWidget(appWidgetId, UnreadWidgetProvider.buildUpdate(ctx, appWidgetId));
    }
    t.stop();
}
Also used : AppWidgetManager(android.appwidget.AppWidgetManager) ComponentName(android.content.ComponentName) Timing(com.newsrob.util.Timing)

Aggregations

AppWidgetManager (android.appwidget.AppWidgetManager)53 ComponentName (android.content.ComponentName)33 RemoteViews (android.widget.RemoteViews)26 Intent (android.content.Intent)21 PendingIntent (android.app.PendingIntent)12 Bundle (android.os.Bundle)12 SharedPreferences (android.content.SharedPreferences)7 Context (android.content.Context)5 View (android.view.View)4 Uri (android.net.Uri)3 AppWidgetProvider (android.appwidget.AppWidgetProvider)2 PackageManager (android.content.pm.PackageManager)2 Cursor (android.database.Cursor)2 Button (android.widget.Button)2 EditText (android.widget.EditText)2 TextView (android.widget.TextView)2 Account (android.accounts.Account)1 Service (android.app.Service)1 AppWidgetProviderInfo (android.appwidget.AppWidgetProviderInfo)1 ContentResolver (android.content.ContentResolver)1