B4A Library External Displays

Android has had official support for external displays since version 4.2.
Prior to version 4.2 some devices had hardware that was capable of outputting a display signal to an external display but control of this output was implemented by the device manufacturer.
Generally the external display would mirror the device's primary display and that was it.

There was no standard API to control external displays until android version 4.2.
Android version 4.2 introduced the Presentation class.
A Presentation is a container for displaying a user interface on an external display.

An external display could now be configured to display any custom user interface - as well as still being able to simply mirror the device's primary display.

An external display is a display that is temporarily connected to a device.
Examples are:
  • TV or projector connected to device using an HDMI cable or MHL adapter.
  • TV or projector connected to device using the Miracast wireless protocol.
    This includes a Samsung device using Samsung's AllShare Cast technology - AllShare Cast is Samsung's proprietary implementation of the Miracast protocol.
  • TV or projector connected to device using a SlimPort cable.

Whereas a primary display is a display that the device normally uses for output.
A TV or projector connected to an android TV stick or OUYA device is still a primary display and not an external display as it is the display that the device normally uses for output.

A Chromecast device is not presently classified as an external display.
A Chromecast device is a media streaming device that can be told to playback a media resource - it will retrieve and display that media resource.
The Chromecast can be told to display a media resource by various methods: an android or iOS application or the desktop Chrome browser can tell a Chromecast device what media resource to display.
But the Chromecast is not currently an external display - i say currently as there is the possibility that Google will update the Chromecast firmware so that it behaves as an external display - but that is just a possibility and may or (more likely) may not happen.

But in this thread i'll publish my attempts to wrap the parts of the android API that allow control over both external displays and Chromecast devices.

If you do not have a device which you can connect to an external display then you are not out of luck - as long as your device is running android 4.2 or later.
In your device's Developer Options under the Drawing category you should find an option to Simulate secondary displays.
Give that option a click and you'll be presented with a list of available emulated secondary displays.
Select an option from that list and a small window will be overlaid on the device display - that small window is a software emulated external display and can be used as an alternative to a real external display.
You can tap and drag the window around the screen so as to not obscure a part of the device's main screen that you need to interact with.

I'll keep this thread tidy by attaching all library files to this first post.

Martin.
 

Attachments

  • CWAC-Presentation_library_files_v0.30.zip
    28.5 KB · Views: 514
  • ExternalDisplays-20140422.zip
    148.4 KB · Views: 597

MarcoRome

Expert
Licensed User
Hi all.
When i compile ExternalDisplaysDemo i have this message error:
B4X:
Parsing code.                           0.11
Compiling code.                         0.42
 
ObfuscatorMap.txt file created in Objects folder.
Compiling layouts code.                 0.06
Generating R file.                      Error
C:\Android\extras\android\support\v7\appcompat\res\values-v21\styles_base.xml:75: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ActionButton'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\styles_base.xml:79: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ActionButton.CloseMode'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\styles_base.xml:83: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ActionButton.Overflow'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\styles_base.xml:25: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ActionBar.TabView'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\styles_base.xml:29: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Light.ActionBar.TabView'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\styles_base.xml:33: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ActionBar.TabText'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\styles_base.xml:37: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Light.ActionBar.TabText'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\styles_base.xml:41: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Light.ActionBar.TabText'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\styles_base.xml:65: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.ActionMode.Title'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\styles_base.xml:69: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.ActionMode.Subtitle'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\styles_base.xml:45: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.ActionBar.Menu'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\styles_base.xml:49: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.ActionBar.Title'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\styles_base.xml:53: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.ActionBar.Subtitle'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\styles_base.xml:57: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.ActionBar.Title.Inverse'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\styles_base.xml:61: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.ActionBar.Subtitle.Inverse'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\styles_base.xml:178: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ProgressBar.Horizontal'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\styles_base.xml:182: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ProgressBar'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\styles_base.xml:113: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Spinner'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\styles_base.xml:115: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Spinner'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\styles_base.xml:110: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.DropDownItem.Spinner'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\styles_base.xml:107: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ListView.DropDown'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\styles_base.xml:121: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ListView'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\styles_base.xml:126: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ListPopupWindow'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\styles_base.xml:138: error: Error: No resource found that matches the given name: attr 'android:overlapAnchor'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\styles_base.xml:143: error: Error: No resource found that matches the given name: attr 'android:overlapAnchor'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\styles_base.xml:129: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.PopupMenu'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\styles_base.xml:132: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Light.PopupMenu'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\styles_base.xml:146: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.PopupMenu.Large'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\styles_base.xml:150: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.PopupMenu.Small'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\styles_base.xml:154: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.PopupMenu.Large'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\styles_base.xml:158: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.PopupMenu.Small'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\styles_base.xml:164: error: Error retrieving parent for item: No resource found that matches the given name '@android:TextAppearance.Material.SearchResult.Title'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\styles_base.xml:168: error: Error retrieving parent for item: No resource found that matches the given name '@android:TextAppearance.Material.SearchResult.Subtitle'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\styles_base.xml:172: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.AutoCompleteTextView'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\styles_base.xml:174: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.AutoCompleteTextView'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\styles_base.xml:93: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Toolbar.Button.Navigation'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\styles_base.xml:97: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.ActionBar.Title'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\styles_base.xml:101: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.ActionBar.Subtitle'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\styles_base_text.xml:62: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Button'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\styles_base_text.xml:20: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\styles_base_text.xml:22: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Display4'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\styles_base_text.xml:24: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Display3'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\styles_base_text.xml:26: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Display2'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\styles_base_text.xml:28: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Display1'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\styles_base_text.xml:30: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Headline'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\styles_base_text.xml:32: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Title'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\styles_base_text.xml:34: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Subhead'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\styles_base_text.xml:36: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Body2'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\styles_base_text.xml:38: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Body1'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\styles_base_text.xml:40: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Caption'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\styles_base_text.xml:42: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Menu'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\styles_base_text.xml:60: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Button'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\styles_base_text.xml:46: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Inverse'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\styles_base_text.xml:48: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Large'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\styles_base_text.xml:50: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Large.Inverse'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\styles_base_text.xml:52: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Medium'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\styles_base_text.xml:54: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Medium.Inverse'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\styles_base_text.xml:56: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Small'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\styles_base_text.xml:58: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Small.Inverse'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\themes_base.xml:26: error: Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Material'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\themes_base.xml:31: error: Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Material.Light'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\themes_base.xml:36: error: Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Material.Dialog'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\themes_base.xml:41: error: Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Material.Light.Dialog'.
C:\Android\extras\android\support\v7\appcompat\res\values-v11\themes_base.xml:338: error: Error: No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
C:\Android\extras\android\support\v7\appcompat\res\values-v14\themes_base.xml:29: error: Error: No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
C:\Android\extras\android\support\v7\appcompat\res\values-v11\themes_base.xml:345: error: Error: No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
C:\Android\extras\android\support\v7\appcompat\res\values-v14\themes_base.xml:37: error: Error: No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
C:\Android\extras\android\support\v7\appcompat\res\values-v11\themes_base.xml:352: error: Error: No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
C:\Android\extras\android\support\v7\appcompat\res\values-v14\themes_base.xml:45: error: Error: No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
C:\Android\extras\android\support\v7\appcompat\res\values-v11\themes_base.xml:359: error: Error: No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
C:\Android\extras\android\support\v7\appcompat\res\values-v14\themes_base.xml:53: error: Error: No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\themes_base.xml:202: error: Error retrieving parent for item: No resource found that matches the given name 'android:ThemeOverlay.Material'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\themes_base.xml:212: error: Error retrieving parent for item: No resource found that matches the given name 'android:ThemeOverlay.Material.Light'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\themes_base.xml:205: error: Error retrieving parent for item: No resource found that matches the given name 'android:ThemeOverlay.Material.Dark'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\themes_base.xml:219: error: Error retrieving parent for item: No resource found that matches the given name 'android:ThemeOverlay.Material.ActionBar'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\themes_base.xml:223: error: Error retrieving parent for item: No resource found that matches the given name 'android:ThemeOverlay.Material.Dark.ActionBar'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\themes_base.xml:81: error: Error: No resource found that matches the given name: attr 'android:colorAccent'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\themes_base.xml:83: error: Error: No resource found that matches the given name: attr 'android:colorControlActivated'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\themes_base.xml:84: error: Error: No resource found that matches the given name: attr 'android:colorControlHighlight'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\themes_base.xml:82: error: Error: No resource found that matches the given name: attr 'android:colorControlNormal'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\themes_base.xml:79: error: Error: No resource found that matches the given name: attr 'android:colorPrimary'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\themes_base.xml:80: error: Error: No resource found that matches the given name: attr 'android:colorPrimaryDark'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\themes_base.xml:118: error: Error: No resource found that matches the given name: attr 'android:colorAccent'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\themes_base.xml:120: error: Error: No resource found that matches the given name: attr 'android:colorControlActivated'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\themes_base.xml:121: error: Error: No resource found that matches the given name: attr 'android:colorControlHighlight'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\themes_base.xml:119: error: Error: No resource found that matches the given name: attr 'android:colorControlNormal'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\themes_base.xml:116: error: Error: No resource found that matches the given name: attr 'android:colorPrimary'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\themes_base.xml:117: error: Error: No resource found that matches the given name: attr 'android:colorPrimaryDark'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\themes_base.xml:155: error: Error: No resource found that matches the given name: attr 'android:colorAccent'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\themes_base.xml:157: error: Error: No resource found that matches the given name: attr 'android:colorControlActivated'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\themes_base.xml:158: error: Error: No resource found that matches the given name: attr 'android:colorControlHighlight'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\themes_base.xml:156: error: Error: No resource found that matches the given name: attr 'android:colorControlNormal'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\themes_base.xml:153: error: Error: No resource found that matches the given name: attr 'android:colorPrimary'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\themes_base.xml:154: error: Error: No resource found that matches the given name: attr 'android:colorPrimaryDark'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\themes_base.xml:192: error: Error: No resource found that matches the given name: attr 'android:colorAccent'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\themes_base.xml:194: error: Error: No resource found that matches the given name: attr 'android:colorControlActivated'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\themes_base.xml:195: error: Error: No resource found that matches the given name: attr 'android:colorControlHighlight'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\themes_base.xml:193: error: Error: No resource found that matches the given name: attr 'android:colorControlNormal'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\themes_base.xml:190: error: Error: No resource found that matches the given name: attr 'android:colorPrimary'.
C:\Android\extras\android\support\v7\appcompat\res\values-v21\themes_base.xml:191: error: Error: No resource found that matches the given name: attr 'android:colorPrimaryDark'.

in configuration B4A i have this:
B4X:
C:\Android\platforms\android-19\android.jar
Any idea ?
Thank you

Hi all.

1. I add this line in code:

B4X:
#Region  Project Attributes
    #ApplicationLabel: ExternalDisplays
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
    #AdditionalRes: C:\Android\extras\android\support\v7\appcompat\res, android.support.v7.appcompat
    #AdditionalRes: C:\Android\extras\android\support\v7\mediarouter\res, android.support.v7.mediarouter
    #AdditionalRes: D:\TV\cwac-mediarouter-res, com.commonsware.cwac.mediarouter
#End Region

2. Add in Library Folder this file:
  • android-support-v7-appcompat.jar
  • android-support-v7-mediarouter.jar
3. Verify that exist all file in C:\Android\extras\android\support\v7\appcompat\libs...etc. and all ok


Why i have again this error ? Depend new SDK ?

Thank you all
Marco
 

thedesolatesoul

Expert
Licensed User
Thanks. Was thinking more towards Chromecast. I think the new SDK may have broken the previous example.
Possibly. There are actually multiple ways to use Chromecast, and the SDK has been updated many times since this library was published.
 

ac9ts

Active Member
Licensed User
Setting the android.jar to Marshmallow (android-23\android.jar) allows the example code to compile. I haven't tested functionality.
 

ac9ts

Active Member
Licensed User
I receive the following when running on any pre-Lollipop system. It appears that there is a missing resource on the MediaRouteButton. I'm not sure where to look to correct this as I'm not to familiar with the inner workings of Java. I do NOT get this error when running on Android v5.0.1. I will also mention that I have only tested on Android 2.3.7 and 4.1.1 using GenyMotion and both a real device and GenyMotion for Android 5.x



** Activity (main) Create, isFirst = true **
main_activity_create (java line: 347)
android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x2/d=0x7f010022 a=2}
at android.content.res.Resources.loadDrawable(Resources.java:1681)
at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
at android.view.View.<init>(View.java:1951)
at com.commonsware.cwac.mediarouter.MediaRouteButton.<init>(MediaRouteButton.java:122)
at com.commonsware.cwac.mediarouter.MediaRouteButton.<init>(MediaRouteButton.java:118)
at com.commonsware.cwac.mediarouter.MediaRouteButton.<init>(MediaRouteButton.java:114)
at uk.co.martinpearman.b4a.cwac.mediarouter.MediaRouteButton.innerInitialize(MediaRouteButton.java:29)
at anywheresoftware.b4a.objects.ViewWrapper.Initialize(ViewWrapper.java:65)
at uk.co.martinpearman.b4a.cwac.mediarouter.MediaRouteButton.Initialize(MediaRouteButton.java:22)
at uk.co.martinpearman.b4a.externaldisplaysdemo.main._activity_create(main.java:347)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:187)
at uk.co.martinpearman.b4a.externaldisplaysdemo.main.afterFirstLayout(main.java:100)
at uk.co.martinpearman.b4a.externaldisplaysdemo.main.access$100(main.java:17)
at uk.co.martinpearman.b4a.externaldisplaysdemo.main$WaitForLayout.run(main.java:78)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3683)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)
android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x2/d=0x7f010022 a=2}
 

ac9ts

Active Member
Licensed User
I have a working version (files attached) that will connect to my Chromecast and start a MP3 stream. The problem I now have is that when I try to open the disconnect dialog, I get the following:


MediaRouterCallback onRouteSelected
java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at android.support.v7.app.AppCompatDelegateImplBase.onCreate(AppCompatDelegateImplBase.java:112)
at android.support.v7.app.AppCompatDelegateImplV7.onCreate(AppCompatDelegateImplV7.java:148)
at android.support.v7.app.AppCompatDialog.<init>(AppCompatDialog.java:48)
at android.support.v7.app.AlertDialog.<init>(AlertDialog.java:92)
at android.support.v7.app.AlertDialog.<init>(AlertDialog.java:88)
at android.support.v7.app.MediaRouteControllerDialog.<init>(MediaRouteControllerDialog.java:98)
at android.support.v7.app.MediaRouteControllerDialog.<init>(MediaRouteControllerDialog.java:94)
at com.commonsware.cwac.mediarouter.MediaRouteControllerDialogFragment.onCreateControllerDialog(MediaRouteControllerDialogFragment.java:55)
at com.commonsware.cwac.mediarouter.MediaRouteControllerDialogFragment.onCreateDialog(MediaRouteControllerDialogFragment.java:60)
at android.app.DialogFragment.getLayoutInflater(DialogFragment.java:398)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:904)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1082)
at android.app.BackStackRecord.run(BackStackRecord.java:833)
at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1467)
at android.app.FragmentManagerImpl$1.run(FragmentManager.java:452)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5942)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)

Again, I really don't know the inner workings of Android to decipher what I need to change.
 

Attachments

  • ExternalDisplays2.zip
    24.1 KB · Views: 114
  • cwac-mediarouter-res.zip
    75.6 KB · Views: 90

gmh

New Member
Licensed User
Hi Martin, Luv'n your work. Made small donation (Aussie dollar not as strong as it was).

I'm also getting the error re "missing resource on the MediaRouteButton" similar to @ac9ts. It complies ok and the apk in #25 worked, so it must be something I'm doing re SDK files:)
 

ac9ts

Active Member
Licensed User
@gmh, the files I have in post 130 work. The problem was solved by changing the theme (and using the correct syntax :oops:) in the manifest. It's a simple app that will connect and play and mp3. There are still some issues with disconnecting but the disconnect dialog does come up which was fixed by the theme change.
 

Rick Harris

Well-Known Member
Licensed User
Hello Martin,

Do you have B4A sourcecode (library) that will work properly with the second generation Chromecast?
There are two kinds of Chromecast: for video and for audio. I would like to use a Chromecast in conjunction with my elaborate "ARTI" app for visually impaired users (www.artipal.com)

Best Regards
Rick
 

MarcoRome

Expert
Licensed User
Hi All
Example @ac9ts work with out problem ( ChromeCast II )
A question:
is it possible send Activity in chromecast ? or is possible send 2 "link" ( mp3 for audio + mp4 without audio, so i can see a mp4 with mp3 as voice ) ?
For now example i have:

B4X:
RemotePlaybackClient1.Play("http://xxxx", "audio/mpeg3", 0, Null)

but if i add another link, in chromecast run only last link that i set.

Thank you
 

MarcoRome

Expert
Licensed User
Hi @warwound , all
is possible send entire screen device in place of a link.
Basically i can send on the device screen instead of sending a link ?

As in this movie:

Thank you very much
Marco
 
Last edited:

Star-Dust

Expert
Licensed User
I'd guess that your b4a additional libraries folder does not contain a required file.
Probably one of these:
  • android-support-v7-appcompat.jar
  • android-support-v7-mediarouter.jar

Martin.

[edit]
You only need Core and ExternalDisplay libraries.
[/edit]

I have setting the android.jar - android-23.
I use adapter Digicom amcast-L01
I have add in libraru folder;
  • android-support-v7-appcompat.jar
  • android-support-v7-mediarouter.jar
  • android-support-v4.jar
I have had this problem and I have not even solved by changing the theme in the Manifest as ac9ts. You give me some help?



LogCat connected to: 0123456789ABCDEF
--------- beginning of /dev/log/system
--------- beginning of /dev/log/main
** Activity (main) Create, isFirst = true **
main_activity_create (java line: 363)
android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x2/d=0x7f010030 a=3}
at android.content.res.Resources.loadDrawable(Resources.java:1967)
at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
at android.view.View.<init>(View.java:3335)
at com.commonsware.cwac.mediarouter.MediaRouteButton.<init>(MediaRouteButton.java:122)
at com.commonsware.cwac.mediarouter.MediaRouteButton.<init>(MediaRouteButton.java:118)
at com.commonsware.cwac.mediarouter.MediaRouteButton.<init>(MediaRouteButton.java:114)
at uk.co.martinpearman.b4a.cwac.mediarouter.MediaRouteButton.innerInitialize(MediaRouteButton.java:29)
at anywheresoftware.b4a.objects.ViewWrapper.Initialize(ViewWrapper.java:65)
at uk.co.martinpearman.b4a.cwac.mediarouter.MediaRouteButton.Initialize(MediaRouteButton.java:22)
at uk.co.martinpearman.b4a.externaldisplaysdemo.main._activity_create(main.java:363)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
at uk.co.martinpearman.b4a.externaldisplaysdemo.main.afterFirstLayout(main.java:102)
at uk.co.martinpearman.b4a.externaldisplaysdemo.main.access$000(main.java:17)
at uk.co.martinpearman.b4a.externaldisplaysdemo.main$WaitForLayout.run(main.java:80)
at android.os.Handler.handleCallback(Handler.java:725)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:153)
at android.app.ActivityThread.main(ActivityThread.java:5297)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
at dalvik.system.NativeStart.main(Native Method)
android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x2/d=0x7f010030 a=3}
 

Martin Beukes

Member
Licensed User
Hi Warwound,

Someone has picked it up from Jobs forum. Once it is working I will be in contact for you to update this post with the new library.

Regards,
Martin
 
Top