-2

I don't understand why google decided to not implement support for custom views or even support for the ones bundled in the support library when designing widgets, and instead it decided to rely on RemoteViews

Widgets are such a big part of users interaction with the app, I'm sure many developers found themselves forced to change plans due to this limitation

Is there a specific reason why this was made, maybe related to performances or?

For example, now i would like to implement a recycler view in one widget but I can't, and I don't understand why it has to be so hard to design one and with so much boilerplate code

3
  • 1
    why google decided if you want to know real reason, then you have to ask google, not us. Just take it as it is. Here you can only get the answer for What is your opinion of why google did it? question, not the one you asked. Jul 25, 2018 at 12:40
  • Well since I cannot directly ask google I was hoping to find someone that could illuminate me :) Jul 25, 2018 at 12:46
  • It's probably to make the OS look uniform and attractive. If every developer had their way, the notification bar would be bloated with unattractive views. Moreover, the synergy of the notification bar would take a hit. Jul 25, 2018 at 12:54

1 Answer 1

1

Widgets are such a big part of users interaction with the app

Few apps implement app widgets.

Is there a specific reason why this was made

Both the host of the app widget (e.g., home screen/launcher) and the publisher of the app widget need to agree on what UI elements can be used and how they can be configured.

For example, you seem to want to use a RecyclerView. That's fine, however, your app does not render the app widget. The host is the one that needs to render the UI of the app widget. So, if you were to use a RecyclerView, your app widget would fail on all hosts that lack RecyclerView support for app widgets. This includes:

  • All hosts that have not been updated since before RecyclerView was introduced (e.g., home screens on older devices)

  • All hosts that did not bother to bundle in RecyclerView in their apps

  • All hosts that did not bother to bundle in whatever the code would be that would cause app widget rendering to support RecyclerView

This coordination gets very complex with hundreds or thousands of hosts and tens or hundreds of thousands of app widgets.

Plus, where does it stop? You think that using RecyclerView is reasonable, and the next person will think that using Facebook's Litho is reasonable, and the person after that will think that using some obscure custom View found on the Android Arsenal is reasonable.

The simple approach for ensuring this agreement is to use a common definition in the framework classes, like RemoteViews, so there is a guaranteed-consistent definition between host and app widget provider. However, RemoteViews is difficult to change in a backwards-compatible fashion, which is why Google has only done it once to date (API Level 11, with the introduction of AdapterView-based options, such as ListView). And framework classes know nothing about libraries, such as those providing RecyclerView or Litho.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.