Hello,
i´m doing a wrap for Google CAST Companion library.
Manifest file
Your AndroidManifest.xml file needs to include certain elements and metadata for the library
and Cast SDK proper operation. Here is a list of requirements:
● Minimum SDK version: the minimum SDK version that the library works with is 10
(GingerBread 2.3.3).
● Permissions: using the cast functionality does not require any additional permissions. If,
however, you have enabled Wifi Reconnection, then you need to add the following two
permissions:
metadata to your application declaration:
For example, you may need to use a variant of Theme.AppCompat or one that inherits from
these themes. Note that this is not a requirement for Cast, per se.
● Declare the VideoCastControllerActivity:
There are a few things that you need to set in the above snippet. Assume that user clicks
on your application’s notification from the status bar while casting. The desired behavior
is to open your application and direct user to the VideoCastControllerActivity .
However, this is not the main launcher activity of your application, so if the user were to
press the back button, she should not be sent out of the application. The correct
behavior would be to send the user to the parent activity; the one that in a normal
execution of your application would show up when user goes back from the
VideoCastControllerActivity . This special behavior can be achieved by creating a
“back stack” for the PendingIntent in the notification service. CCL can handle this for you
if you declare in the manifest what activity is the correct parent activity; you need to enter
the name of that activity (possibly a fully qualified name) in the two places in the above
snippet where the *PARENT_ACTIVITY* is used 9. In addition, the
VideoCastControllerActivity is best presented if you use an overlay Action Bar theme;
the CastVideos reference app defines one ( DemocastOverlay ) that you can copy and use,
or you can define your own theme; it should replace the *AN_OVERLAY_THEME* in the
above snippet.
● Declare the following receiver:
from Lock Screen) where it broadcasts a message that this receiver catches and
handles appropriately. There is no need to define any Intent Filter for this receiver.
● Declare the following service (for VideoCastNotificationService ):
● Declare the following service (for ReconnectionService ) if Wifi Reconnection has been
enabled:
information
● If you want to enable Captions in the preferences, declare the following activity in your
manifest:
I tried to use this manifest code to add the needed things:
I´m not sure if
The Apps packagename is de.donmanfred.cast and i want to reference the Main activity as Parent of the Castactivity.
But when i try to compile i get the error
But i dont know WHICH token is invalid.
Can anybody bring some light into this?
i´m doing a wrap for Google CAST Companion library.
Manifest file
Your AndroidManifest.xml file needs to include certain elements and metadata for the library
and Cast SDK proper operation. Here is a list of requirements:
● Minimum SDK version: the minimum SDK version that the library works with is 10
(GingerBread 2.3.3).
● Permissions: using the cast functionality does not require any additional permissions. If,
however, you have enabled Wifi Reconnection, then you need to add the following two
permissions:
● Application Metadata: like any application that uses the Play Services, add the following<uses‐permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses‐permission android:name="android.permission.ACCESS_WIFI_STATE" />
metadata to your application declaration:
● Makes sure your application’s “theme” is correctly set based on the min SDK version.<meta‐data android:name="com.google.android.gms.version"
android:value="@Integer/google_play_services_version" />
For example, you may need to use a variant of Theme.AppCompat or one that inherits from
these themes. Note that this is not a requirement for Cast, per se.
● Declare the VideoCastControllerActivity:
<activity
android:name="com.google.android.libraries.cast.companionlibrary.cast.player.V
ideoCastControllerActivity"
android:screenOrientation="portrait"
android:label="@string/app_name"
android:launchMode="singleTask"
androidarentActivityName="*MY_PARENT_ACTIVITY*"
android:theme="*AN_OVERLAY_THEME*">
<meta‐data
android:name="android.support.PARENT_ACTIVITY"
android:value="*MY_PARENT_ACTIVITY*" />
<intent‐filter>
<action android:name="android.intent.action.MAIN" />
</intent‐filter>
</activity>
There are a few things that you need to set in the above snippet. Assume that user clicks
on your application’s notification from the status bar while casting. The desired behavior
is to open your application and direct user to the VideoCastControllerActivity .
However, this is not the main launcher activity of your application, so if the user were to
press the back button, she should not be sent out of the application. The correct
behavior would be to send the user to the parent activity; the one that in a normal
execution of your application would show up when user goes back from the
VideoCastControllerActivity . This special behavior can be achieved by creating a
“back stack” for the PendingIntent in the notification service. CCL can handle this for you
if you declare in the manifest what activity is the correct parent activity; you need to enter
the name of that activity (possibly a fully qualified name) in the two places in the above
snippet where the *PARENT_ACTIVITY* is used 9. In addition, the
VideoCastControllerActivity is best presented if you use an overlay Action Bar theme;
the CastVideos reference app defines one ( DemocastOverlay ) that you can copy and use,
or you can define your own theme; it should replace the *AN_OVERLAY_THEME* in the
above snippet.
● Declare the following receiver:
This receiver is called when user interacts with the VideoCastNotificationService (or<receiver
android:name="com.google.android.libraries.cast.companionlibrary.remotecontrol.VideoI
ntentReceiver" />
from Lock Screen) where it broadcasts a message that this receiver catches and
handles appropriately. There is no need to define any Intent Filter for this receiver.
● Declare the following service (for VideoCastNotificationService ):
<service
android:name="com.google.android.libraries.cast.companionlibrary.notification.VideoCa
stNotificationService"/>
● Declare the following service (for ReconnectionService ) if Wifi Reconnection has been
enabled:
9 See http://developer.android.com/guide/topics/ui/notifiers/notifications.html#NotificationResponse for more<service
android:name="com.google.android.libraries.cast.companionlibrary.cast.reconnection.Re
connectionService"/>
information
● If you want to enable Captions in the preferences, declare the following activity in your
manifest:
<activity
android:name="com.google.android.libraries.cast.companionlibrary.cast.tracks.C
aptionsPreferenceActivity"
android:label="@string/action_settings" >
<intent‐filter>
<action android:name="android.intent.action.MAIN" />
</intent‐filter>
</activity>
I tried to use this manifest code to add the needed things:
B4X:
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: https://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="19"/>
<supports-screens android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
'End of default text.
'************ Google Play Services Base ************
AddApplicationText(
<activity android:name="com.google.android.gms.common.api.GoogleApiActivity"
android:theme="@android:style/Theme.Translucent.NoTitleBar"
android:exported="false"/>
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
)
'************ Google Play Services Base (end) ************
'************ Firebase Base ************
CreateResourceFromFile("google-services", "google-services.json")
AddPermission(android.permission.ACCESS_NETWORK_STATE)
AddPermission(android.permission.INTERNET)
AddPermission(android.permission.WAKE_LOCK)
AddPermission(com.google.android.c2dm.permission.RECEIVE)
AddPermission(${applicationId}.permission.C2D_MESSAGE)
AddManifestText( <permission android:name="${applicationId}.permission.C2D_MESSAGE"
android:protectionLevel="signature" />)
AddApplicationText(
<receiver
android:name="com.google.android.gms.measurement.AppMeasurementReceiver"
android:enabled="true">
<intent-filter>
<action android:name="com.google.android.gms.measurement.UPLOAD"/>
</intent-filter>
</receiver>
<service
android:name="com.google.android.gms.measurement.AppMeasurementService"
android:enabled="true"
android:exported="false"/>
<provider
android:authorities="${applicationId}.firebaseinitprovider"
android:name="com.google.firebase.provider.FirebaseInitProvider"
android:exported="false"
android:initOrder="100" />
<receiver
android:name="com.google.android.gms.measurement.AppMeasurementReceiver"
android:enabled="true">
<intent-filter>
<action android:name="com.google.android.gms.measurement.UPLOAD"/>
</intent-filter>
</receiver>
<service
android:name="com.google.android.gms.measurement.AppMeasurementService"
android:enabled="true"
android:exported="false"/>
<receiver
android:name="com.google.firebase.iid.FirebaseInstanceIdReceiver"
android:exported="true"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="${applicationId}" />
</intent-filter>
</receiver>
<receiver
android:name="com.google.firebase.iid.FirebaseInstanceIdInternalReceiver"
android:exported="false" />
<service
android:name="com.google.firebase.iid.FirebaseInstanceIdService"
android:exported="true">
<intent-filter android:priority="-500">
<action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
</intent-filter>
</service>
)
'************ Firebase Base (end) ************
'************ Google CAST ********************
AddApplicationText(<activity
android:name="com.google.android.libraries.cast.companionlibrary.cast.player.VideoCastControllerActivity"
android:screenOrientation="portrait"
android:label="@string/app_name"
android:launchMode="singleTask"
android:parentActivityName=".main"
android:theme="* am overlay theme">
<meta‐data
android:name="android.support.PARENT_ACTIVITY"
android:value=".main" />
<intent‐filter>
<action android:name="android.intent.action.MAIN" />
</intent‐filter>
</activity>
<activity
android:name="com.google.android.libraries.cast.companionlibrary.cast.tracks.CaptionsPreferenceActivity"
android:label="@string/action_settings" >
<intent‐filter>
<action android:name="android.intent.action.MAIN" />
</intent‐filter>
</activity
<receiver
android:name="com.google.android.libraries.cast.companionlibrary.remotecontrol.VideoIntentReceiver" />
<service
android:name="com.google.android.libraries.cast.companionlibrary.notification.VideoCastNotificationService"/>
<service
android:name="com.google.android.libraries.cast.companionlibrary.cast.reconnection.ReconnectionService"/>
)
SetActivityAttribute(Main, android:theme, @style/CustomActTheme)
CreateResource(values, theme.xml,
<resources>
<style name="CustomActTheme" parent="@android:style/ThemeOverlay.Material.Light.ActionBar">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:backgroundDimEnabled">true</item>
<item name="android:windowFullscreen">true</item>
<item name="android:colorPrimary">#f44336</item> <!-- action bar -->
<item name="android:colorPrimaryDark">#b71c1c</item> <!-- status bar -->
<item name="android:colorAccent">#2DEA6A</item> <!-- Seekbar,, checkboxes,, switches,, etc. -->
<item name="android:textColorPrimary">#00FF00</item> <!-- ? -->
<item name="android:textColorSecondary">#FF00FF</item> <!-- inactive editText line,, scrollbar -->
<item name="android:textColor">#000000</item> <!-- menu text,, msgbox title -->
<item name="android:textColorLink">#b71c1c</item>
<item name="android:textColorHighlight">#FF9F9F</item>
</style>
</resources>
)
I´m not sure if
is set correct to the mainactivity of my app... Even not if the following is correct to reference the main activity of the app.androidarentActivityName=".main"
<meta‐data
android:name="android.support.PARENT_ACTIVITY"
android:value=".main" />
The Apps packagename is de.donmanfred.cast and i want to reference the Main activity as Parent of the Castactivity.
But when i try to compile i get the error
B4A version: 6.00
Parsing code. (0.00s)
Compiling code. (0.07s)
Compiling layouts code. (0.00s)
Organizing libraries. (0.00s)
Generating R file. Error
AndroidManifest.xml:89: error: Error parsing XML: not well-formed (invalid token)
But i dont know WHICH token is invalid.
Can anybody bring some light into this?