use of android.appwidget.AppWidgetManager in project android_frameworks_base by ParanoidAndroid.
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)) {
Log.d(TAG, "UPDATE");
// BEGIN_INCLUDE(getExtra_EXTRA_APPWIDGET_IDS)
Bundle extras = intent.getExtras();
int[] appWidgetIds = extras.getIntArray(AppWidgetManager.EXTRA_APPWIDGET_IDS);
// END_INCLUDE(getExtra_EXTRA_APPWIDGET_IDS)
SharedPreferences prefs = context.getSharedPreferences(TestAppWidgetProvider.PREFS_NAME, 0);
String prefix = prefs.getString(PREF_PREFIX_KEY, "hai");
AppWidgetManager gm = AppWidgetManager.getInstance(context);
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.test_appwidget);
views.setTextViewText(R.id.oh_hai_text, prefix + ": " + SystemClock.elapsedRealtime());
if (false) {
gm.updateAppWidget(appWidgetIds, views);
} else {
gm.updateAppWidget(new ComponentName("com.android.tests.appwidgethost", "com.android.tests.appwidgethost.TestAppWidgetProvider"), views);
}
}
}
use of android.appwidget.AppWidgetManager in project android_frameworks_base by ParanoidAndroid.
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);
}
}
}
use of android.appwidget.AppWidgetManager in project SeriesGuide by UweTrottmann.
the class ListWidgetConfigure method onUpdateWidget.
private void onUpdateWidget() {
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(this);
RemoteViews views = ListWidgetProvider.buildRemoteViews(this, appWidgetManager, mAppWidgetId);
appWidgetManager.updateAppWidget(mAppWidgetId, views);
appWidgetManager.notifyAppWidgetViewDataChanged(mAppWidgetId, R.id.list_view);
Intent resultValue = new Intent();
resultValue.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, mAppWidgetId);
setResult(RESULT_OK, resultValue);
finish();
}
use of android.appwidget.AppWidgetManager in project SeriesGuide by UweTrottmann.
the class ListWidgetProvider method notifyAllAppWidgetsViewDataChanged.
/**
* Notifies all list widgets bound to this provider to update their views.
*/
public static void notifyAllAppWidgetsViewDataChanged(@Nullable Context context) {
if (context == null) {
return;
}
// use app context as this may be called by activities that can be destroyed
context = context.getApplicationContext();
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
if (appWidgetManager == null) {
return;
}
int[] appWidgetIds = appWidgetManager.getAppWidgetIds(new ComponentName(context, ListWidgetProvider.class));
if (appWidgetIds == null || appWidgetIds.length == 0) {
return;
}
appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetIds, R.id.list_view);
Timber.d("notifyAllAppWidgetsViewDataChanged: updated list widget contents.");
}
use of android.appwidget.AppWidgetManager in project Fairphone by Kwamecorp.
the class LauncherTransitionable method updateGoogleAppsIntallerWidgets.
public void updateGoogleAppsIntallerWidgets() {
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(this);
int[] appWidgetIds = appWidgetManager.getAppWidgetIds(new ComponentName(this, GoogleAppsInstallerWidget.class));
if (appWidgetIds.length > 0) {
new GoogleAppsInstallerWidget().onUpdate(this, appWidgetManager, appWidgetIds);
}
}
Aggregations