public class

ViewerTileUpdateRequester

extends java.lang.Object

implements TileUpdateRequester

 java.lang.Object

↳androidx.wear.tiles.ViewerTileUpdateRequester

Gradle dependencies

compile group: 'androidx.wear.tiles', name: 'tiles', version: '1.4.0'

  • groupId: androidx.wear.tiles
  • artifactId: tiles
  • version: 1.4.0

Artifact androidx.wear.tiles:tiles:1.4.0 it located at Google repository (https://maven.google.com/)

Overview

TileUpdateRequester which notifies the viewer app that it should fetch a new version of the Timeline.

Summary

Fields
public static final java.lang.StringACTION_REQUEST_TILE_UPDATE

The intent action used so a Tile Provider can request that the platform fetches a new Timeline from it.

Constructors
publicViewerTileUpdateRequester(Context context)

Methods
public voidrequestUpdate(java.lang.Class<Service> tileProvider)

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Fields

public static final java.lang.String ACTION_REQUEST_TILE_UPDATE

The intent action used so a Tile Provider can request that the platform fetches a new Timeline from it.

Constructors

public ViewerTileUpdateRequester(Context context)

Methods

public void requestUpdate(java.lang.Class<Service> tileProvider)

Source

/*
 * Copyright 2021 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package androidx.wear.tiles;

import android.app.Service;
import android.content.Context;
import android.content.Intent;

import androidx.annotation.NonNull;

/**
 * {@link TileUpdateRequester} which notifies the viewer app that it should fetch a new version
 * of the Timeline.
 */
public class ViewerTileUpdateRequester implements TileUpdateRequester {
    /**
     * The intent action used so a Tile Provider can request that the platform fetches a new
     * Timeline from it.
     */
    public static final String ACTION_REQUEST_TILE_UPDATE =
            "androidx.wear.tiles.action.REQUEST_TILE_UPDATE";

    private final Context mContext;

    public ViewerTileUpdateRequester(@NonNull Context context) {
        this.mContext = context;
    }

    @Override
    public void requestUpdate(@NonNull Class<? extends Service> tileProvider) {
        mContext.sendBroadcast(buildUpdateIntent(mContext.getPackageName()));
    }

    private static Intent buildUpdateIntent(String packageName) {
        Intent i = new Intent(ACTION_REQUEST_TILE_UPDATE);
        i.setPackage(packageName);

        return i;
    }
}