Android Question Cast to TV (Solved)

Colin Evans

Active Member
Licensed User
Longtime User
Hi, just wondered if anyone has used code to Cast the screen to TV, i.e. make a connection to the device and then screen mirror. Does anyone think it's possible
 

Colin Evans

Active Member
Licensed User
Longtime User
Wow I sorted it , hopefully prove of use to others

B4X:
#Region  Project Attributes
    #ApplicationLabel: DITL CastToTV
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Private xui As XUI
End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    Private btnCast As Button
    Private ImageView1 As ImageView
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("Layout")
    'btnCast.Initialize("btnCast")
End Sub

Sub btnCast_Click
    Dim i As Intent
    i.Initialize("android.settings.CAST_SETTINGS", "")
    Try
        StartActivity(i)
    Catch
        Try
            i.Initialize("android.settings.WIRELESS_SETTINGS","")
            StartActivity(i)
            ToastMessageShow("Please select Cast/Screen Mirroring",True)
        Catch
            ToastMessageShow("Casting not supported on this device",True)
            Log(LastException)
        End Try
    End Try
End Sub


Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub Button1_Click
    xui.MsgboxAsync("Hello world!", "B4X")
End Sub
{/code]
 
Upvote 0
Top