mwieczorek
mwieczorek

Reputation: 2252

How to tell if Intent was from Google Cast notification

I've setup casting abilities with the notification controls. The issue I'm having is that I need to differentiate between when a User clicks on the notification (that spawns the activity) and any other time the activity was created.

I would think this can be done by adding an intent-filter to the receiver entity in the manifest:

    <receiver android:name=".services.CastIntentReceiver">
        <intent-filter>
           something goes here?
        </intent-filter>
    </receiver>

This is basically needed so I can rebuild the View where I house the Cast Controller after the activity is re-launched from the notification. Without any differentiation, the implementation interferes with the functionality I built for the View rebuilding after orientation change (since they both use onResume())

Thanks in advance for any help.

Upvotes: 1

Views: 353

Answers (1)

Android Enthusiast
Android Enthusiast

Reputation: 4960

Try to read Media Route Provider. Media Route allows to play media content from their Android devices, allowing Android users to instantly show a picture, play a song or share a video.

The Android media router framework allows manufacturers to enable playback on their devices through a standardized interface called a MediaRouteProvider. A route provider defines a common interface for playing media on a receiver device, making it possible to play media on your equipment from any Android application that supports media routes.

A media route provider is distributed as part of an Android app. Your route provider can be made available to other apps by extending MediaRouteProviderService or wrapping your implementation of MediaRouteProvider with your own service and declaring an intent filter for the media route provider. These steps allow other apps to discover and make use of your media route.

There are two main types of playback supported by the media router framework. A media route provider can support one or both types of playback, depending on the capabilities of your playback equipment and the functionality you want to support:

  • Remote Playback — This approach uses the receiver device to handle the content data retrieval, decoding, and playback, while an Android device in the user's hand is used as a remote control. This approach is used by Android apps that support Google Cast.
  • Secondary Output — With this approach, the Android media application retrieves, renders and streams video or music directly to the receiver device. This approach is used to support Wireless Display output on Android.

    <service android:name=".provider.SampleMediaRouteProviderService" android:label="@string/sample_media_route_provider_service" android:process=":mrp"> <intent-filter> <action android:name="android.media.MediaRouteProviderService" /> </intent-filter> </service>

    public class SampleMediaRouteProviderService extends MediaRouteProviderService {
    @Override public MediaRouteProvider onCreateMediaRouteProvider() { return new SampleMediaRouteProvider(this); } }

Upvotes: 1

Related Questions