B4A Library IR Control for Samsung Smart TV

The attached project is based on this b4a library and project that I have posted before. It is an IR remote control for a Samsung Smart TV. Your device needs to support and IR blaster to make use of this B4A library and B4A project (such as the Samsung S4 mini with KitKat)

Found most of the pronto hex codes here. The attached project controls my Samsung Smart TV 100%.

Pronto hex codes used (inside the B4A project):
B4X:
Dim ProgUp As String = "0000 006d 0022 0003 00a9 00a8 0015 003f 0015 003f 0015 003f 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 003f 0015 003f 0015 003f 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 003f 0015 0015 0015 0015 0015 003f 0015 0015 0015 0015 0015 0015 0015 003f 0015 0015 0015 003f 0015 003f 0015 0015 0015 0040 0015 003f 0015 003f 0015 0702 00a9 00a8 0015 0015 0015 0e6e"
    Dim ProgDown As String = "0000 006d 0022 0003 00a9 00a8 0015 003f 0015 003f 0015 003f 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 003f 0015 003f 0015 003f 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 003f 0015 0015 0015 0015 0015 0015 0015 003f 0015 003f 0015 003f 0015 003f 0015 0015 0015 003f 0015 003f 0015 003f 0015 0702 00a9 00a8 0015 0015 0015 0e6e"
    Dim VolUp As String = "0000 006d 0022 0003 00a9 00a8 0015 003f 0015 003f 0015 003f 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 003f 0015 003f 0015 003f 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 003f 0015 003f 0015 003f 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 003f 0015 003f 0015 003f 0015 003f 0015 003f 0015 0702 00a9 00a8 0015 0015 0015 0e6e"
    Dim VolDown As String = "0000 006d 0022 0003 00a9 00a8 0015 003f 0015 003f 0015 003f 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 003f 0015 003f 0015 003f 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 003f 0015 003f 0015 0015 0015 003f 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 003f 0015 0015 0015 003f 0015 003f 0015 003f 0015 003f 0015 0702 00a9 00a8 0015 0015 0015 0e6e"
    Dim pwr As String = "0000 006d 0022 0003 00a9 00a8 0015 003f 0015 003f 0015 003f 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 003f 0015 003f 0015 003f 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 003f 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0040 0015 0015 0015 003f 0015 003f 0015 003f 0015 003f 0015 003f 0015 003f 0015 0702 00a9 00a8 0015 0015 0015 0e6e"
    Dim OK As String = "0000 006D 0000 0022 00AC 00AB 0015 0041 0015 0041 0015 0041 0015 0016 0015 0016 0015 0016 0015 0016 0015 0016 0015 0041 0015 0041 0015 0041 0015 0016 0015 0016 0015 0016 0015 0016 0015 0016 0015 0016 0015 0016 0015 0016 0015 0041 0015 0016 0015 0041 0015 0041 0015 0016 0015 0041 0015 0041 0015 0041 0015 0016 0015 0041 0015 0016 0015 0016 0015 0041 0015 0689"
    Dim Menu As String = "0000 006D 0000 0022 00AC 00AB 0015 0041 0015 0041 0015 0041 0015 0016 0015 0016 0015 0016 0015 0016 0015 0016 0015 0041 0015 0041 0015 0041 0015 0016 0015 0016 0015 0016 0015 0016 0015 0016 0015 0016 0015 0041 0015 0016 0015 0041 0015 0041 0015 0016 0015 0016 0015 0016 0015 0041 0015 0016 0015 0041 0015 0016 0015 0016 0015 0041 0015 0041 0015 0041 0015 0689"
    Dim info As String = "0000 006D 0000 0022 00AC 00AB 0015 0041 0015 0041 0015 0041 0015 0016 0015 0016 0015 0016 0015 0016 0015 0016 0015 0041 0015 0041 0015 0041 0015 0016 0015 0016 0015 0016 0015 0016 0015 0016 0015 0041 0015 0041 0015 0041 0015 0041 0015 0041 0015 0016 0015 0016 0015 0016 0015 0016 0015 0016 0015 0016 0015 0016 0015 0016 0015 0041 0015 0041 0015 0041 0015 0689"
    Dim ex As String = "0000 006D 0000 0022 00AC 00AB 0015 0041 0015 0041 0015 0041 0015 0016 0015 0016 0015 0016 0015 0016 0015 0016 0015 0041 0015 0041 0015 0041 0015 0016 0015 0016 0015 0016 0015 0016 0015 0016 0015 0041 0015 0016 0015 0041 0015 0041 0015 0016 0015 0041 0015 0016 0015 0016 0015 0016 0015 0041 0015 0016 0015 0016 0015 0041 0015 0016 0015 0041 0015 0041 0015 0689"
    Dim mute As String = "0000 006D 0000 0022 00AA 00AA 0015 003F 0015 003F 0015 003F 0015 0014 0015 0015 0015 0015 0015 0015 0015 0015 0015 003F 0015 003F 0015 003F 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 003F 0015 003F 0015 003F 0015 003F 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0014 0015 003F 0015 003F 0015 003F 0015 003F 0015 0715"
    Dim source As String = "0000 006D 0000 0022 00AA 00AA 0015 003F 0015 003F 0015 003F 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 003F 0015 003F 0015 003F 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 003F 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 003F 0015 003F 0015 003F 0015 003F 0015 003F 0015 003F 0015 003F 0015 0715"
    Dim up As String = "0000 006D 0000 0022 00AC 00AB 0015 0041 0015 0041 0015 0041 0015 0016 0015 0016 0015 0016 0015 0016 0015 0016 0015 0041 0015 0041 0015 0041 0015 0016 0015 0016 0015 0016 0015 0016 0015 0016 0015 0016 0015 0016 0015 0016 0015 0016 0015 0016 0015 0041 0015 0041 0015 0016 0015 0041 0015 0041 0015 0041 0015 0041 0015 0041 0015 0016 0015 0016 0015 0041 0015 0689"
    Dim down As String = "0000 006D 0000 0022 00AC 00AB 0015 0041 0015 0041 0015 0041 0015 0016 0015 0016 0015 0016 0015 0016 0015 0016 0015 0041 0015 0041 0015 0041 0015 0016 0015 0016 0015 0016 0015 0016 0015 0016 0015 0041 0015 0016 0015 0016 0015 0016 0015 0016 0015 0041 0015 0041 0015 0016 0015 0016 0015 0041 0015 0041 0015 0041 0015 0041 0015 0016 0015 0016 0015 0041 0015 0689"
    Dim left As String = "0000 006D 0000 0022 00AC 00AB 0015 0041 0015 0041 0015 0041 0015 0016 0015 0016 0015 0016 0015 0016 0015 0016 0015 0041 0015 0041 0015 0041 0015 0016 0015 0016 0015 0016 0015 0016 0015 0016 0015 0041 0015 0016 0015 0041 0015 0016 0015 0016 0015 0041 0015 0041 0015 0016 0015 0016 0015 0041 0015 0016 0015 0041 0015 0041 0015 0016 0015 0016 0015 0041 0015 0689"
    Dim right As String = "0000 006D 0000 0022 00AC 00AB 0015 0041 0015 0041 0015 0041 0015 0016 0015 0016 0015 0016 0015 0016 0015 0016 0015 0041 0015 0041 0015 0041 0015 0016 0015 0016 0015 0016 0015 0016 0015 0016 0015 0016 0015 0041 0015 0016 0015 0016 0015 0016 0015 0041 0015 0041 0015 0016 0015 0041 0015 0016 0015 0041 0015 0041 0015 0041 0015 0016 0015 0016 0015 0041 0015 0689"
    'HDMI 1 and HDMI 2 are working on my Samsung Smart TV (3 and 4 probably for TV's supporting 3/4 HDMI ports)
    Dim hdmi1 As String = "0000 006D 0000 0022 00AC 00AC 0015 0040 0015 0040 0015 0040 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0040 0015 0040 0015 0040 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0040 0015 0015 0015 0015 0015 0040 0015 0015 0015 0040 0015 0040 0015 0040 0015 0015 0015 0040 0015 0040 0015 0015 0015 0040 0015 0015 0015 0015 0015 0015 0015 0689"
    Dim hdmi2 As String = "0000 006D 0000 0022 00AC 00AC 0015 0040 0015 0040 0015 0040 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0040 0015 0040 0015 0040 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0040 0015 0040 0015 0040 0015 0040 0015 0040 0015 0015 0015 0040 0015 0040 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0040 0015 0015 0015 0689"
    Dim hdmi3 As String = "0000 006D 0000 0022 00AC 00AC 0015 0040 0015 0040 0015 0040 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0040 0015 0040 0015 0040 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0040 0015 0015 0015 0015 0015 0015 0015 0015 0015 0040 0015 0040 0015 0040 0015 0015 0015 0040 0015 0040 0015 0040 0015 0040 0015 0015 0015 0015 0015 0689"
    Dim hdmi4 As String = "0000 006D 0000 0022 00AC 00AB 0015 0041 0015 0041 0015 0041 0015 0016 0015 0016 0015 0016 0015 0016 0015 0016 0015 0041 0015 0041 0015 0041 0015 0016 0015 0016 0015 0016 0015 0016 0015 0016 0015 0041 0015 0016 0015 0041 0015 0016 0015 0016 0015 0016 0015 0041 0015 0041 0015 0016 0015 0041 0015 0016 0015 0041 0015 0041 0015 0041 0015 0016 0015 0016 0015 0689"

You will need the following libs to be enabled in your B4A project:
1. JavaObject
2. Phone
3. StringUtils
4. AndroidInfrared (attached as the B4A lib files - extract them and copy the jar and xml to your additional libs folder.

1.png
 

Attachments

  • b4aLibFiles.zip
    14.5 KB · Views: 388
  • b4aSamsungTV.zip
    253.7 KB · Views: 334

Johan Schoeman

Expert
Licensed User
Longtime User
B4A Sample code:
B4X:
#Region  Project Attributes
    #ApplicationLabel: b4aSamsungTV
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: portrait
    #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.

End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.

    Private ssstv As AndroidInfrared
    Private vu As VibrateUtilities
   
    Private btnPower As Button

    Dim ProgUp As String = "0000 006d 0022 0003 00a9 00a8 0015 003f 0015 003f 0015 003f 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 003f 0015 003f 0015 003f 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 003f 0015 0015 0015 0015 0015 003f 0015 0015 0015 0015 0015 0015 0015 003f 0015 0015 0015 003f 0015 003f 0015 0015 0015 0040 0015 003f 0015 003f 0015 0702 00a9 00a8 0015 0015 0015 0e6e"
    Dim ProgDown As String = "0000 006d 0022 0003 00a9 00a8 0015 003f 0015 003f 0015 003f 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 003f 0015 003f 0015 003f 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 003f 0015 0015 0015 0015 0015 0015 0015 003f 0015 003f 0015 003f 0015 003f 0015 0015 0015 003f 0015 003f 0015 003f 0015 0702 00a9 00a8 0015 0015 0015 0e6e"
    Dim VolUp As String = "0000 006d 0022 0003 00a9 00a8 0015 003f 0015 003f 0015 003f 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 003f 0015 003f 0015 003f 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 003f 0015 003f 0015 003f 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 003f 0015 003f 0015 003f 0015 003f 0015 003f 0015 0702 00a9 00a8 0015 0015 0015 0e6e"
    Dim VolDown As String = "0000 006d 0022 0003 00a9 00a8 0015 003f 0015 003f 0015 003f 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 003f 0015 003f 0015 003f 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 003f 0015 003f 0015 0015 0015 003f 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 003f 0015 0015 0015 003f 0015 003f 0015 003f 0015 003f 0015 0702 00a9 00a8 0015 0015 0015 0e6e"
    Dim pwr As String = "0000 006d 0022 0003 00a9 00a8 0015 003f 0015 003f 0015 003f 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 003f 0015 003f 0015 003f 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 003f 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0040 0015 0015 0015 003f 0015 003f 0015 003f 0015 003f 0015 003f 0015 003f 0015 0702 00a9 00a8 0015 0015 0015 0e6e"
    Dim OK As String = "0000 006D 0000 0022 00AC 00AB 0015 0041 0015 0041 0015 0041 0015 0016 0015 0016 0015 0016 0015 0016 0015 0016 0015 0041 0015 0041 0015 0041 0015 0016 0015 0016 0015 0016 0015 0016 0015 0016 0015 0016 0015 0016 0015 0016 0015 0041 0015 0016 0015 0041 0015 0041 0015 0016 0015 0041 0015 0041 0015 0041 0015 0016 0015 0041 0015 0016 0015 0016 0015 0041 0015 0689"
    Dim Menu As String = "0000 006D 0000 0022 00AC 00AB 0015 0041 0015 0041 0015 0041 0015 0016 0015 0016 0015 0016 0015 0016 0015 0016 0015 0041 0015 0041 0015 0041 0015 0016 0015 0016 0015 0016 0015 0016 0015 0016 0015 0016 0015 0041 0015 0016 0015 0041 0015 0041 0015 0016 0015 0016 0015 0016 0015 0041 0015 0016 0015 0041 0015 0016 0015 0016 0015 0041 0015 0041 0015 0041 0015 0689"
    Dim info As String = "0000 006D 0000 0022 00AC 00AB 0015 0041 0015 0041 0015 0041 0015 0016 0015 0016 0015 0016 0015 0016 0015 0016 0015 0041 0015 0041 0015 0041 0015 0016 0015 0016 0015 0016 0015 0016 0015 0016 0015 0041 0015 0041 0015 0041 0015 0041 0015 0041 0015 0016 0015 0016 0015 0016 0015 0016 0015 0016 0015 0016 0015 0016 0015 0016 0015 0041 0015 0041 0015 0041 0015 0689"
    Dim ex As String = "0000 006D 0000 0022 00AC 00AB 0015 0041 0015 0041 0015 0041 0015 0016 0015 0016 0015 0016 0015 0016 0015 0016 0015 0041 0015 0041 0015 0041 0015 0016 0015 0016 0015 0016 0015 0016 0015 0016 0015 0041 0015 0016 0015 0041 0015 0041 0015 0016 0015 0041 0015 0016 0015 0016 0015 0016 0015 0041 0015 0016 0015 0016 0015 0041 0015 0016 0015 0041 0015 0041 0015 0689"
    Dim mute As String = "0000 006D 0000 0022 00AA 00AA 0015 003F 0015 003F 0015 003F 0015 0014 0015 0015 0015 0015 0015 0015 0015 0015 0015 003F 0015 003F 0015 003F 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 003F 0015 003F 0015 003F 0015 003F 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0014 0015 003F 0015 003F 0015 003F 0015 003F 0015 0715"
    Dim source As String = "0000 006D 0000 0022 00AA 00AA 0015 003F 0015 003F 0015 003F 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 003F 0015 003F 0015 003F 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 003F 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 003F 0015 003F 0015 003F 0015 003F 0015 003F 0015 003F 0015 003F 0015 0715"
    Dim up As String = "0000 006D 0000 0022 00AC 00AB 0015 0041 0015 0041 0015 0041 0015 0016 0015 0016 0015 0016 0015 0016 0015 0016 0015 0041 0015 0041 0015 0041 0015 0016 0015 0016 0015 0016 0015 0016 0015 0016 0015 0016 0015 0016 0015 0016 0015 0016 0015 0016 0015 0041 0015 0041 0015 0016 0015 0041 0015 0041 0015 0041 0015 0041 0015 0041 0015 0016 0015 0016 0015 0041 0015 0689"
    Dim down As String = "0000 006D 0000 0022 00AC 00AB 0015 0041 0015 0041 0015 0041 0015 0016 0015 0016 0015 0016 0015 0016 0015 0016 0015 0041 0015 0041 0015 0041 0015 0016 0015 0016 0015 0016 0015 0016 0015 0016 0015 0041 0015 0016 0015 0016 0015 0016 0015 0016 0015 0041 0015 0041 0015 0016 0015 0016 0015 0041 0015 0041 0015 0041 0015 0041 0015 0016 0015 0016 0015 0041 0015 0689"
    Dim left As String = "0000 006D 0000 0022 00AC 00AB 0015 0041 0015 0041 0015 0041 0015 0016 0015 0016 0015 0016 0015 0016 0015 0016 0015 0041 0015 0041 0015 0041 0015 0016 0015 0016 0015 0016 0015 0016 0015 0016 0015 0041 0015 0016 0015 0041 0015 0016 0015 0016 0015 0041 0015 0041 0015 0016 0015 0016 0015 0041 0015 0016 0015 0041 0015 0041 0015 0016 0015 0016 0015 0041 0015 0689"
    Dim right As String = "0000 006D 0000 0022 00AC 00AB 0015 0041 0015 0041 0015 0041 0015 0016 0015 0016 0015 0016 0015 0016 0015 0016 0015 0041 0015 0041 0015 0041 0015 0016 0015 0016 0015 0016 0015 0016 0015 0016 0015 0016 0015 0041 0015 0016 0015 0016 0015 0016 0015 0041 0015 0041 0015 0016 0015 0041 0015 0016 0015 0041 0015 0041 0015 0041 0015 0016 0015 0016 0015 0041 0015 0689"
    'HDMI 1 and HDMI 2 are working on my Samsung Smart TV (3 and 4 probably for TV's supporting 3/4 HDMI ports)
    Dim hdmi1 As String = "0000 006D 0000 0022 00AC 00AC 0015 0040 0015 0040 0015 0040 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0040 0015 0040 0015 0040 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0040 0015 0015 0015 0015 0015 0040 0015 0015 0015 0040 0015 0040 0015 0040 0015 0015 0015 0040 0015 0040 0015 0015 0015 0040 0015 0015 0015 0015 0015 0015 0015 0689"
    Dim hdmi2 As String = "0000 006D 0000 0022 00AC 00AC 0015 0040 0015 0040 0015 0040 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0040 0015 0040 0015 0040 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0040 0015 0040 0015 0040 0015 0040 0015 0040 0015 0015 0015 0040 0015 0040 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0040 0015 0015 0015 0689"
    Dim hdmi3 As String = "0000 006D 0000 0022 00AC 00AC 0015 0040 0015 0040 0015 0040 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0040 0015 0040 0015 0040 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0040 0015 0015 0015 0015 0015 0015 0015 0015 0015 0040 0015 0040 0015 0040 0015 0015 0015 0040 0015 0040 0015 0040 0015 0040 0015 0015 0015 0015 0015 0689"
    Dim hdmi4 As String = "0000 006D 0000 0022 00AC 00AB 0015 0041 0015 0041 0015 0041 0015 0016 0015 0016 0015 0016 0015 0016 0015 0016 0015 0041 0015 0041 0015 0041 0015 0016 0015 0016 0015 0016 0015 0016 0015 0016 0015 0041 0015 0016 0015 0041 0015 0016 0015 0016 0015 0016 0015 0041 0015 0041 0015 0016 0015 0041 0015 0016 0015 0041 0015 0041 0015 0041 0015 0016 0015 0016 0015 0689"


    Private tbnCHup As Button
    Private btnCHdown As Button
    Private Spinner1 As Spinner
    Private btnMute As Button
    Private btnVolumeUp As Button
    Private btnVolumeDown As Button
    Private btnOK As Button
    Private arrowLeft As ImageView
    Private arrowRight As ImageView
    Private arrowUp As ImageView
    Private arrowDown As ImageView
    Private btnInfo As Button
    Private btnExit As Button
    Private imgStop As ImageView
    Private imgPausePlay As ImageView
    Private btn1 As Button
    Private btn2 As Button
    Private btn3 As Button
    Private btn4 As Button
    Private btn5 As Button
    Private btn6 As Button
    Private btn7 As Button
    Private btn8 As Button
    Private btn9 As Button
    Private btn0 As Button
    Private btnOptions As Button
    Private btndstv As Button
    Private btnHelp As Button
    Private btnPlaylist As Button
    Private btnBoxOffice As Button
'    Private btnAudio As Button
    Private btnTV As Button
    Private btnTVguide As Button
    Private btnCatchUp As Button
    Private btnPG As Button
    Private btnARC As Button

'    Private btnAC As Button
    Private btnStop As Button
    Private btnPlay As Button
    Private btnRecord As Button
    Dim smalltext As Float
    Dim stu As StringUtils
    Dim ph As PhoneWakeState
   
    Dim ll As Int  = 0
    Private btnSearch As Button
    Private imvRewind As ImageView
    Private imvFF As ImageView
    Private btnAlt As Button

End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("main")
    ll = 1
   
    ssstv.Initialize("")
    vu.Initialize


End Sub

Sub Activity_Resume
    smalltext = 100
    ph.KeepAlive(True)
    Log(ssstv.hasIrEmitter)
    If ll = 1 Then
      scale_text
      ll = 0
    End If 

End Sub

Sub Activity_Pause (UserClosed As Boolean)
   
    ph.ReleaseKeepAlive

End Sub


Sub btnPower_Click
   
    vu.vibrateOnce(50)
    ssstv.Pronto = pwr
   
End Sub



Sub Wait(MilliSekunden As Int)
    Dim Ti As Long
    Ti = DateTime.Now + MilliSekunden
    Do While DateTime.Now < Ti
        Sleep(0)
    Loop
End Sub



Sub tbnCHup_Click
   
    vu.vibrateOnce(50)
    ssstv.Pronto = ProgUp
    Wait(100)
   
End Sub

Sub btnCHdown_Click
   
    vu.vibrateOnce(50)
    ssstv.Pronto = ProgDown
    Wait(100)
   
End Sub

Sub Spinner1_ItemClick (Position As Int, Value As Object)
   

   
End Sub

Sub btnMute_Click
   
    vu.vibrateOnce(50)
    ssstv.Pronto = mute
    Wait(100)
   
End Sub

Sub btnVolumeUp_Click
   
    vu.vibrateOnce(50)
    ssstv.Pronto = VolUp

    Wait(100)
   
End Sub

Sub btnVolumeDown_Click
   
    vu.vibrateOnce(50)
    ssstv.Pronto = VolDown

    Wait(100)
   
End Sub

Sub btnOK_Click
   
    vu.vibrateOnce(50)
    ssstv.Pronto = OK
    Wait(100)
   
End Sub

Sub arrowLeft_Click
   
    vu.vibrateOnce(50)
    arrowLeft.Bitmap = LoadBitmap(File.DirAssets,"arrowleftred.png")
    Wait(200)
    ssstv.Pronto = left
    arrowLeft.Bitmap = LoadBitmap(File.DirAssets,"arrowleftwhite.png")
    Wait(200)
   
   
End Sub

Sub arrowRight_Click
   
    vu.vibrateOnce(50)
    arrowRight.Bitmap = LoadBitmap(File.DirAssets,"arrowrightred.png")
    Wait(200)
    ssstv.Pronto = right
    arrowRight.Bitmap = LoadBitmap(File.DirAssets,"arrowrightwhite.png")
    Wait(200)
   
   
End Sub

Sub arrowUp_Click
   
    vu.vibrateOnce(50)
    arrowUp.Bitmap = LoadBitmap(File.DirAssets,"arrowupred.png")
    Wait(200)
    ssstv.Pronto = up
    arrowUp.Bitmap = LoadBitmap(File.DirAssets,"arrowupwhite.png")
    Wait(200)
   
End Sub

Sub arrowDown_Click
   
    vu.vibrateOnce(50)
    arrowDown.Bitmap = LoadBitmap(File.DirAssets,"arrowdownred.png")
    Wait(200)
    ssstv.Pronto = down
    arrowDown.Bitmap = LoadBitmap(File.DirAssets,"arrowdownwhite.png")
    Wait(200)
   
End Sub

Sub btnInfo_Click

    vu.vibrateOnce(50)
    ssstv.Pronto = info
    Wait(100)
   
   
End Sub

Sub btnExit_Click
   
    vu.vibrateOnce(50)
    ssstv.Pronto = ex
    Wait(100)   
   
End Sub


Sub btnTVguide_Click
    vu.vibrateOnce(50)
    ssstv.Pronto = Menu
    Wait(100)
   
End Sub



Sub btnARC_Click
    vu.vibrateOnce(50)
    ssstv.Pronto = hdmi1
    Wait(100)
   
End Sub


Sub btnStop_Click
    vu.vibrateOnce(50)
    ssstv.Pronto = hdmi3
    Wait(100)
   
End Sub

Sub btnPlay_Click
    vu.vibrateOnce(50)
    ssstv.Pronto = hdmi2
    Wait(100)
   
End Sub

Sub btnRecord_Click
   
    vu.vibrateOnce(50)
    ssstv.Pronto = source
    Wait(100)
   
End Sub

Sub btnSearch_Click
   
    vu.vibrateOnce(50)
    ssstv.Pronto = hdmi4
    Wait(100)

End Sub


Sub scale_text

    For Each v As View In Activity.GetAllViewsRecursive
        If v Is Button Then
            Dim jo As JavaObject = v
            Dim btn As Button
            btn=v
            SetButtonTextSize(btn,btn.Text)
            jo.RunMethod("setPadding",Array As Object(0,0,0,10dip))     'left, top, right, bottom
        End If

        If v Is EditText Then
            Dim jo As JavaObject = v
            Dim et As EditText
            et=v
            SetEditTextSize(et,et.Text)
            jo.RunMethod("setPadding",Array As Object(0,0,0,0))
        End If

        If v Is Label Then
            Dim jo As JavaObject = v
            Dim la As Label
            la=v
            SetLabelTextSize(la,la.Text)
            jo.RunMethod("setPadding",Array As Object(0,0,0,0))
        End If
       
    
    Next

    For Each v As View In Activity.GetAllViewsRecursive
        If v Is Button Then
            Dim jo As JavaObject = v
            Dim btn As Button
            btn=v
            btn.TextSize = smalltext
        End If
    Next
   
End Sub

Sub SetLabelTextSize(ex1 As Label, txt As String)
    Dim dt As Float
    Dim limit = 0.95 As Float
    Dim h As Int
 
    ex1.Text = txt
    ex1.TextSize = 72
    dt = ex1.TextSize
    h = stu.MeasureMultilineTextHeight(ex1, txt)
    Do While dt > limit Or h > ex1.Height
        dt = dt / 2
        h = stu.MeasureMultilineTextHeight(ex1, txt)
        If h > ex1.Height Then
            ex1.TextSize = ex1.TextSize - dt
        Else
            ex1.TextSize = ex1.TextSize + dt
        End If
    Loop
    ex1.TextSize=ex1.textsize * 0.95
    If ex1.TextSize < smalltext Then smalltext = ex1.TextSize
End Sub

Sub SetEditTextSize(ex1 As EditText, txt As String)
    Dim dt As Float
    Dim limit = 0.5 As Float
    Dim h As Int
 
    ex1.Text = txt
    ex1.TextSize = 72
    dt = ex1.TextSize
    h = stu.MeasureMultilineTextHeight(ex1, txt)
    Do While dt > limit Or h > ex1.Height
        dt = dt / 2
        h = stu.MeasureMultilineTextHeight(ex1, txt)
        If h > ex1.Height Then
            ex1.TextSize = ex1.TextSize - dt
        Else
            ex1.TextSize = ex1.TextSize + dt
        End If
    Loop
    ex1.TextSize=ex1.textsize *0.9
    If ex1.TextSize < smalltext Then smalltext = ex1.TextSize
End Sub

Sub SetButtonTextSize(ex1 As Button, txt As String)
    Dim dt As Float
    Dim limit = 0.95 As Float
    Dim h As Int
 
    ex1.Text = txt
    ex1.TextSize =72
    dt = ex1.TextSize
    h = stu.MeasureMultilineTextHeight(ex1, txt)
    Do While dt > limit Or h > ex1.Height
        dt = dt / 2
        h = stu.MeasureMultilineTextHeight(ex1, txt)
        If h > ex1.Height Then
            ex1.TextSize = ex1.TextSize - dt
        Else
            ex1.TextSize = ex1.TextSize + dt
        End If
    Loop
    ex1.TextSize = ex1.textsize * 0.95
    If ex1.TextSize < smalltext Then smalltext = ex1.TextSize
    ex1.TextColor = Colors.White
End Sub
 

Johan Schoeman

Expert
Licensed User
Longtime User
B4A Manifest:
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="19" android:targetSdkVersion="22"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
AddManifestText(<uses-feature android:name="android.hardware.consumerir" android:required="true" />)
'AddManifestText(<uses-permission android:name="com.sony.remotecontrol.permission.API"/>)

'End of default text.
AddPermission("android.permission.VIBRATE")
'SetApplicationAttribute(android:theme, "@style/MyAppTheme")
'SetActivityAttribute(act_seek, android:theme, @style/CustomActTheme)
CreateResource(values, theme.xml,
<resources>
  <style name="CustomActTheme" parent="@android:style/Theme.Material">
  <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>
)
 
Top