Reputation: 95
From my configure activity the user can select his/hers desired font size of the widget. I set the font size like this:
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget);
views.setFloat(R.id.tvConfigInput, "setTextSize", 25);
But I do not how to update the Widget with the selected size
Any suggestions?
Thanks
Upvotes: 3
Views: 1085
Reputation: 1006664
What you have should work, as setTextSize()
is a RemotableViewMethod
(at least in the current source code) and therefore should work with RemoteViews
.
First, try your app widget on an Android 4.2 emulator and see if it works. If it does, then the answer is that setTextSize()
is usable on Android 4.2, is not usable on whatever environment you originally tried, and should become usable somewhere in between them.
Otherwise, make sure that you are actually updating the app widget, using AppWidgetManager
and methods like updateAppWidget()
.
Upvotes: 0
Reputation: 14022
You have to use your AppWidgetManager.For example in onReceive() method of your AppWidgetProvider do some things like this:
@Override
public void onReceive(Context context, Intent intent) {
views = new RemoteViews(context.getPackageName(),
R.layout.widget);
AppWidgetManager mManager = AppWidgetManager.getInstance(context);
ComponentName cn = new ComponentName(context,YourAppWidgetProvider.class);
...
mManager.updateAppWidget(cn, views);
}
Here YourAppWidgetProvider
is name of class that extends AppWidgetProvider
.
Upvotes: 1