Android – how to launch different activities for different content in the actor sender application on the mini control click

I am adding Google cast support to the application, and I can only locate one activity to start on the microcontroller and notification click. I configure it in the optionsprovider subclass

   @Override
    public CastOptions getCastOptions(Context appContext) {

        Log.d(TAG, "getCastOptions: ");

        NotificationOptions notificationOptions = new NotificationOptions.Builder()
                .setTargetActivityClassName(VideoPlayerActivity.class.getName())
                .build();

        CastMediaOptions mediaOptions = new CastMediaOptions.Builder()
                .setNotificationOptions(notificationOptions)
                .setExpandedControllerActivityClassName(VideoPlayerActivity.class.getName())
                .build();

        CastOptions castOptions = new CastOptions.Builder()
                .setReceiverApplicationId(appContext.getString(R.string.app_id))
                .setCastMediaOptions(mediaOptions)
                .build();
        return castOptions;
    }

It's OK to play video, but I can also play music in the app, and there is no full screen controller. Therefore, on the notification / mini controller, if you want to project video, click "I want to start videoplayeractivity". When you want to project music, click "musicactivity"

The problem cannot be resolved and cannot be found in the document. I'm not sure if I can

How can I achieve it?

resolvent:

Define an activity (such as proxyactivity) as your target activity. Then, in the activity, determine whether it is music or video, and then start the corresponding activity; Proxyactivity does nothing but decide which of the other two activities to start

An alternative is to adapt your target activity to the media type (i.e. handle two situations in one activity)

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>