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

Cast receiver app not launching on android 11 for the first time when tv starts #132

Open
shubhamrb opened this issue Aug 25, 2023 · 0 comments

Comments

@shubhamrb
Copy link

shubhamrb commented Aug 25, 2023

### NOTE: This problem is happening on android 11 or higher android tv only when i first time start the tv or the tv in screensaver/sleep mode instead it opens the fallback url on web receiver

Sender Option provider

public class CustomCastOptionsProvider implements OptionsProvider {

@Override
public CastOptions getCastOptions(Context context) {
    List<String> supportedNamespaces = new ArrayList<>();
    supportedNamespaces.add(context.getString(R.string.custom_namespace));
    LaunchOptions launchOptions = new LaunchOptions.Builder()
            .setAndroidReceiverCompatible(true)
            .build();
    return new CastOptions.Builder()
            .setReceiverApplicationId(context.getString(R.string.cast_application_id))
            .setSupportedNamespaces(supportedNamespaces)
            .setLaunchOptions(launchOptions)
            .build();
}

@Override
public java.util.List<SessionProvider> getAdditionalSessionProviders(Context context) {
    return null;
}

}

Sender AndroidManifest.xml

Sender start session

castContext.getSessionManager().endCurrentSession(true);
Intent castIntent = new Intent();
castIntent.putExtra("CAST_INTENT_TO_CAST_ROUTE_ID_KEY", route.getId());
castIntent.putExtra("CAST_INTENT_TO_CAST_DEVICE_NAME_KEY", route.getName());
castIntent.putExtra("CAST_INTENT_TO_CAST_NO_TOAST_KEY", false);
castContext.getSessionManager().startSession(castIntent);

Receiver options provider

public class MyReceiverOptionsProvider implements ReceiverOptionsProvider {

@Override
public CastReceiverOptions getOptions(Context context) {
    List<String> supportedNamespaces = new ArrayList<>();
    supportedNamespaces.add(context.getString(R.string.custom_namespace));
    return new CastReceiverOptions.Builder(context)
            .setCustomNamespaces(supportedNamespaces)
            .setCastAppId(context.getString(R.string.cast_application_id))
            .build();
}

}

receiver AndroidManifest.xml

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
<uses-permission android:name="com.android.providers.tv.permission.WRITE_EPG_DATA" />
<uses-permission android:name="android.permission.READ_EPG_DATA" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />

<uses-feature
    android:name="android.hardware.touchscreen"
    android:required="false" />
<uses-feature
    android:name="android.hardware.faketouch"
    android:required="false" />
<uses-feature
    android:name="android.hardware.telephony"
    android:required="false" />
<uses-feature
    android:name="android.hardware.camera"
    android:required="false" />
<uses-feature
    android:name="android.hardware.nfc"
    android:required="false" />
<uses-feature
    android:name="android.hardware.location.gps"
    android:required="false" />
<uses-feature
    android:name="android.hardware.microphone"
    android:required="false" />
<uses-feature
    android:name="android.hardware.sensor"
    android:required="false" />
<uses-feature
    android:name="android.hardware.wifi"
    android:required="false" />
<uses-feature
    android:name="android.hardware.dpad"
    android:required="false" />
<uses-feature
    android:name="android.software.leanback"
    android:required="true" />

<application
    android:name=".FrenziApplication"
    android:allowBackup="true"
    android:banner="@mipmap/ic_banner_foreground"
    android:icon="@mipmap/ic_banner_foreground"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/Theme.Frenzi">

    <activity
        android:name=".activity.FirstActivity"
        android:configChanges="keyboard|keyboardHidden|navigation"
        android:exported="true">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LEANBACK_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>
        <intent-filter>
            <action android:name="com.google.android.gms.cast.tv.action.LOAD" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>

    <activity
        android:name=".activity.WelcomeActivity"
        android:configChanges="keyboard|keyboardHidden|navigation"
        android:exported="true">
        <intent-filter
            android:autoVerify="true"
            tools:targetApi="m">
            <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />

            <data android:scheme="https" />
            <data android:host="www.myfrenzi.com" />
            <data android:pathPattern=".*" />
            <data android:scheme="https" />
            <data android:host="myfrenzi.com" />
            <data android:pathPattern=".*" />
        </intent-filter>
        <intent-filter>
            <action android:name="com.google.android.gms.cast.tv.action.LOAD" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
    <activity
        android:name=".activity.LoginActivity"
        android:exported="false"
        android:windowSoftInputMode="adjustPan" />

    <activity
        android:name=".activity.NavigationActivity"
        android:exported="false" />
    <activity
        android:name=".activity.MainActivity"
        android:exported="false" />

    <meta-data
        android:name="com.google.android.gms.cast.tv.RECEIVER_OPTIONS_PROVIDER_CLASS_NAME"
        android:value="com.frenzi.tv.MyReceiverOptionsProvider" />
</application>
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

1 participant