androidx / androidx/media

notifyChildrenChanged - mark which children changed so that browsers can reload specific items only

Open
#3,042 6 comments 0 reactions 1 assignee View on GitHub

@tonihei is already working on this.

Since Feb 6, 2026.

enhancement
Dominant language
Java
Stars
3k
Forks
955
Avg merge
12d 14h
Merged PRs (30d)
2

Description

Hello,

MediaBrowserServiceCompat has notifyChildrenChanged takes a bundle that can be used to specify the page that the changed children belongs to.

fun notifySpecificPageChanged(parentId: String, page: Int, pageSize: Int) {
        val options = Bundle().apply {
            putInt(MediaBrowserCompat.EXTRA_PAGE, page)
            putInt(MediaBrowserCompat.EXTRA_PAGE_SIZE, pageSize)
        }

        notifyChildrenChanged(parentId, options)
    }

This bundle is used in MediaBrowserCompatUtils.hasDuplicatedItems to decide when not to notify based on active subscribed page from connected browsers.

void notifyChildrenChangedForCompatOnHandler(
        ConnectionRecord connection, String parentId, @Nullable Bundle options) {
      List<Pair<@NullableType IBinder, @NullableType Bundle>> callbackList =
          connection.subscriptions.get(parentId);
      if (callbackList != null) {
        for (Pair<@NullableType IBinder, @NullableType Bundle> callback : callbackList) {
          if (MediaBrowserCompatUtils.hasDuplicatedItems(options, callback.second)) {
            performLoadChildren(parentId, connection, callback.second, options);
          }
        }
      }
    }

However, it is possible that multiple clients could have used different page configurations. How to notify only the applicable ones? Does the library have any support or does MediaBrowserServiceCompat have to track and notify accordingly?

notifyChildrenChanged() EXTRA_PAGE (0) and EXTRA_PAGE_SIZE (100)

                          ┌─────────────────────────────────┐
                          │         SERVICE                 │
                          │                                 │
                          │   Data: [0, 1, 2, ... 999]      │
                          │                                 │
                          │   ⚡ Item 75 changed            │
                          │                                 │
                          │                                 │
                          └───────────┬─────────────────────┘
                                      │
                    ┌─────────────────┼─────────────────┐
                    │                 │                 │
                    ▼                 ▼                 ▼
     ┌──────────────────┐  ┌──────────────────┐  ┌──────────────────┐
     │  BROWSER A       │  │  BROWSER B       │  │  BROWSER C       │
     │                  │  │                  │  │                  │
     │  Page: 0         │  │  Page: 0         │  │  Page: 0         │
     │  Size: 100       │  │  Size: 50        │  │  Size: 200       │
     │                  │  │                  │  │                  │
     │  Subscribed to:  │  │  Subscribed to:  │  │  Subscribed to:  │
     │  items [0-99]    │  │  items [0-49]    │  │  items [0-199]   │
     │                  │  │                  │  │                  │
     └──────────────────┘  └──────────────────┘  └──────────────────┘

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.