Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Supported methods on RemoteViews

Tags:

android

I am trying to forward values to an Android RemoteView. Some values can be forwarded via the set methods that use reflection. Eg background color works:

rv.setInt(R.id.viewId, "setBackgroundColor", 0xffff0000);

Although that mechanism looks pretty generic for one param methods calls, it doesn't work for certain methods. Eg. setting the alpha on a view doesn't work (running on api level 15):

rv.setFloat(R.id.viewId, "setAlpha", 0.5f);

The framework complains at runtime that setAlpha(float) is not supported. Does anybody know why that is the case? What is the rule for supported methods on remote view? Why would't alpha be among them?

Update:

The answer from CommonsWare is correct. After some more research it might be interesting for some that ImageView.setAlpha(int) is remotable. It only sets the alpha on the image and therefore does not apply to ninepatches etc. But it could be useful for some.

like image 848
Moritz Avatar asked Jul 07 '12 13:07

Moritz


1 Answers

Does anybody know why that is the case? What is the rule for supported methods on remote view?

setBackgroundColor() has the @RemotableViewMethod annotation. setAlpha() does not.

Why would't alpha be among them?

That could be anything from a concrete technical reason to a simple oversight. You are welcome to either file a feature request on http://b.android.com to have that annotation be added in some future version of Android, or perhaps implement it and submit a patch.

like image 102
CommonsWare Avatar answered Oct 02 '22 17:10

CommonsWare