Guest User

Automagic <-> b4a

a guest
Mar 14th, 2020
470
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #Region  Project Attributes
  2.     #ApplicationLabel: B4A Example
  3.     #VersionCode: 1
  4.     #VersionName:
  5.     'SupportedOrientations possible values: unspecified, landscape or portrait.
  6.     #SupportedOrientations: unspecified
  7.     #CanInstallToExternalStorage: False
  8.     #BridgeLogger: True
  9. #End Region
  10.  
  11. #Region  Activity Attributes
  12.     #FullScreen: False
  13.     #IncludeTitle: True
  14. #End Region
  15.  
  16. Sub Process_Globals
  17.     'These global variables will be declared once when the application starts.
  18.     'These variables can be accessed from all modules.
  19.     Dim BroadCast As BroadCastReceiver
  20. End Sub
  21.  
  22. Sub Globals
  23.     'These global variables will be redeclared each time the activity is created.
  24.     'These variables can only be accessed from this module.
  25.  
  26.     Private SeekBar1 As SeekBar
  27.     Private seek_label As Label
  28. End Sub
  29.  
  30. Sub BroadcastReceiver_OnReceive (Action As String, i As Object) 'https://www.b4x.com/android/forum/threads/broadcastreceiver.12493/
  31.     Dim retIn As Intent
  32.     retIn = i
  33.     Msgbox("Received value from Automagic" & retIn.ExtrasToString,"")
  34.     Log(retIn.ExtrasToString)
  35. End Sub
  36.  
  37. Sub Activity_Create(FirstTime As Boolean)
  38.     'Do not forget to load the layout file created with the visual designer. For example:
  39.     'Activity.LoadLayout("Layout1")
  40.     'Msgbox("Welcome to B4A!", "")
  41.     BroadCast.Initialize("BroadcastReceiver")
  42.     Activity.LoadLayout("b4a_am4a_v1")
  43.     seek_label.Text = SeekBar1.Value
  44.     Log("Started...")
  45.     BroadCast.addAction("b4a.action.1")
  46.     BroadCast.SetPriority(999)
  47.     BroadCast.registerReceiver("")
  48. End Sub
  49.  
  50.  
  51. Sub lvgrm_OFF_Click
  52.     Dim i As Intent
  53.     i.Initialize("automagic.Turn_OFF_lv_light","")
  54.     i.SetComponent("ch.gridvision.ppam.androidautomagic") ',"ch.gridvision.ppam.androidautomagic")
  55.     Dim p As Phone
  56.     p.SendBroadcastIntent(i)
  57.     Msgbox("Sent OFF!", "")
  58. End Sub
  59.  
  60. Sub lvgrm_ON_Click
  61.     Dim i As Intent
  62.     i.Initialize("automagic.Turn_ON_lv_light","")
  63.     i.SetComponent("ch.gridvision.ppam.androidautomagic") ',"ch.gridvision.ppam.androidautomagic")
  64.     Dim p As Phone
  65.     p.SendBroadcastIntent(i)
  66.     Msgbox("Sent ON!", "")
  67.    
  68. End Sub
  69.  
  70. Sub SeekBar1_ValueChanged (Value As Int, UserChanged As Boolean)
  71.     seek_label.Text = Value
  72. End Sub
  73.  
  74. Sub sendAM_Click
  75.     Dim i As Intent
  76.     Dim s As String
  77.     i.Initialize("automagic.b4a_test","")
  78.     i.SetComponent("ch.gridvision.ppam.androidautomagic") ',"ch.gridvision.ppam.androidautomagic")
  79.     s = SeekBar1.Value
  80.     i.PutExtra("param1",s)
  81.     Dim p As Phone
  82.     p.SendBroadcastIntent(i)
  83.     'Msgbox("Sent to Automagic!", "")
  84.    
  85. End Sub
Advertisement
Add Comment
Please, Sign In to add comment