Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android TV App isn't opening #109

Open
playtvgo opened this issue Jul 23, 2021 · 2 comments
Open

Android TV App isn't opening #109

playtvgo opened this issue Jul 23, 2021 · 2 comments

Comments

@playtvgo
Copy link

I want to open android tv app when casting from sender app , but it always opening the web receiver .
I followed this codelab Cast Connect with ATV App and this codelab for Cast-enable an Android app , After that

  • I added my Chromecast as testing device in cast console
  • Signed the ATV app
  • Installed in tv box and tried to cast from the sender app , but it opens the web receiver not the ATV app
    Sender AndroidManifest.xml
        <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
        <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
        <uses-permission android:name="android.permission.WAKE_LOCK" />
        <uses-permission android:name="android.permission.INTERNET" />
    
        <queries>
            <intent>
                <action android:name="android.intent.action.VIEW" />
    
                <data android:mimeType="video/* , application/x-mpegURL" />
            </intent>
        </queries>
    
        <application
            android:icon="@mipmap/ic_launcher"
            android:label="@string/app_name"
            android:networkSecurityConfig="@xml/network_security_config"
            android:protectionLevel="signature"
            android:roundIcon="@mipmap/ic_launcher_round"
            android:supportsRtl="true"
            android:theme="@style/Theme.JMXPlayer"
            android:usesCleartextTraffic="true"
            tools:ignore="UnusedAttribute">
            <meta-data
                android:name="com.google.android.gms.ads.AD_MANAGER_APP"
                android:value="true" />
            <meta-data
                android:name="com.google.android.gms.version"
                android:value="@integer/google_play_services_version" />
            <meta-data
                android:name="com.google.android.gms.cast.framework.OPTIONS_PROVIDER_CLASS_NAME"
                android:value="com.stream.jmxplayer.casty.CastOptionProvider" />
            <meta-data
                android:name="com.google.android.gms.version"
                android:value="@integer/google_play_services_version" /> 

Sender Option Provider class

    
    public class CastOptionProvider implements OptionsProvider {
        @Override
        public CastOptions getCastOptions(Context context) {
            CastOptions customCastOptions = Casty.customCastOptions;
            if (customCastOptions == null) {
                List<String> buttonActions = createButtonActions();
                int[] compatButtonAction = {1, 3};
    
                NotificationOptions notificationOptions = new NotificationOptions.Builder()
                        .setActions(buttonActions, compatButtonAction)
                        .setTargetActivityClassName(ExpandedControlsActivity.class.getName())
                        .build();
    
                CastMediaOptions mediaOptions = new CastMediaOptions.Builder()
                        .setNotificationOptions(notificationOptions)
                        .setExpandedControllerActivityClassName(ExpandedControlsActivity.class.getName())
                        .build();
                LaunchOptions launchOptions = new LaunchOptions.Builder()
                        .setRelaunchIfRunning(true)
                        .setAndroidReceiverCompatible(true).build();
    
                return new CastOptions.Builder()
                        .setReceiverApplicationId(Casty.receiverId)
                        .setCastMediaOptions(mediaOptions)
                        .setLaunchOptions(launchOptions)
                        .build();
            } else {
                return customCastOptions;
            }
        }
    
        private List<String> createButtonActions() {
            return Arrays.asList(MediaIntentReceiver.ACTION_REWIND,
                    MediaIntentReceiver.ACTION_TOGGLE_PLAYBACK,
                    MediaIntentReceiver.ACTION_FORWARD,
                    MediaIntentReceiver.ACTION_STOP_CASTING);
        }
    
        @Override
        public List<SessionProvider> getAdditionalSessionProviders(Context context) {
            return null;
        }
    } 

Receiver AndroidManifest.xml

    <uses-permission android:name="android.permission.INTERNET" />
        <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
        <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    
        <uses-feature
            android:name="android.hardware.touchscreen"
            android:required="false" />
        <uses-feature
            android:name="android.software.leanback"
            android:required="true" />
    
        <application
            android:name=".JmxApplication"
            android:allowBackup="true"
            android:appComponentFactory="androidx.core.app.CoreComponentFactory"
            android:icon="@mipmap/ic_launcher"
            android:label="@string/app_name"
            android:networkSecurityConfig="@xml/network_security_config"
            android:roundIcon="@mipmap/ic_launcher_round"
            android:supportsRtl="true"
            android:theme="@style/Theme.JMXPlayerCast">
    
            <meta-data
                android:name="com.google.android.gms.cast.tv.RECEIVER_OPTIONS_PROVIDER_CLASS_NAME"
                android:value="com.stream.jmxplayercast.CastReceiverOptionsProvider" />
    
            <activity
                android:name=".ui.MainActivity"
                android:banner="@drawable/main_logo"
                android:label="@string/app_name"
                android:launchMode="singleTask"
                android:logo="@drawable/circle_cropped_logo"
                android:screenOrientation="landscape">
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />
    
                    <category android:name="android.intent.category.LEANBACK_LAUNCHER" />
                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
    
                <intent-filter>
                    <action android:name="com.google.android.gms.cast.tv.action.LAUNCH" />
                    <category android:name="android.intent.category.DEFAULT" />
                </intent-filter>
            </activity>
    
            <activity
                android:name=".ui.PlayerActivity"
                android:exported="true"
                android:launchMode="singleTask">
                <intent-filter>
                    <action android:name="com.google.android.gms.cast.tv.action.LOAD" />
                    <category android:name="android.intent.category.DEFAULT" />
                </intent-filter>
    
                <intent-filter>
                    <action android:name="android.intent.action.VIEW" />
    
                    <category android:name="android.intent.category.DEFAULT" />
                    <category android:name="android.intent.category.BROWSABLE" />
    
                    <data android:scheme="http" />
                    <data android:scheme="https" />
                    <data android:mimeType="video/*" />
                    <data android:mimeType="application/*" />
                </intent-filter>
            </activity>
    
        </application>

ReceiverOptionProver class is the vanilla codelab's option provider.
What have I done wrong and how to fix this .. Thanks in Advance

@jtromo
Copy link
Contributor

jtromo commented Sep 27, 2021

Hi,

Have you gone through our Android TV receiver troubleshooting guide? https://developers.google.com/cast/docs/android_tv_receiver/troubleshooting

To confirm, you are not using a LaunchRequestChecker for your Android TV app? Are you seeing any errors such as APP_NOT_INSTALLED_BY_WHITELISTED_INSTALLER or INSTALLER_NOT_WHITELISTED?

@nipunkraj
Copy link

I am also facing the same issue and i logcat i am seeing
App failed to launch. Error: APP_NOT_INSTALLED_BY_WHITELISTED_INSTALLER
2022-04-29 15:46:59.190 4572-4572/? E/cr_CastToNative: Warg launch failed (INSTALLER_NOT_WHITELISTED).

But i have already registered the cast serial no..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants