Version: 1.0
------------------------
BeeperDeLuxe is a B4A Lib.
Features:
Properties:
DurationMillisecond: the duration of the sound, vibration or alarm.
To use you need to implement libs as followes:
Find attached:
------------------------
BeeperDeLuxe is a B4A Lib.
Features:
- sound a beep tone
- vibrate the phone
- sound and vibrate
- sound intermitting alarmtone
Properties:
DurationMillisecond: the duration of the sound, vibration or alarm.
To use you need to implement libs as followes:
- core
- xui
- phone
- audio
Find attached:
- BeeperDeLuxe.zip - B4A Project with Custom Class
- BeeperDeluxe1.zip - B4A lib files
Main Activity:
#Region Project Attributes
#ApplicationLabel: B4A Example
#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 EditTextDuration As EditText
Private ButtonBeep As Button
Private ButtonVibrate As Button
Private ButtonBeepVibrate As Button
Private beeper As BeeperDeLuxe
Private ButtonAlarm As Button
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Layout")
beeper.Initialize
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub EditTextDuration_TextChanged (Old As String, New As String)
ButtonBeep.enabled=True
ButtonBeepVibrate.Enabled=True
ButtonVibrate.Enabled=True
ButtonAlarm.Enabled=True
End Sub
Sub ButtonBeep_Click
beeper.beep(EditTextDuration.text)
End Sub
Sub ButtonVibrate_Click
beeper.Vibrate(EditTextDuration.text)
End Sub
Sub ButtonBeepVibrate_Click
beeper.beepAndVibrate(EditTextDuration.text)
End Sub
Sub ButtonAlarm_Click
beeper.Alarm(EditTextDuration.Text)
End Sub
Custom Class:
' ###############################################
' (C) TechDoc G. Becker - http://gbecker.de
' ###############################################
' Custom View: BeeperDeLuxe
' Language: B4A
' Designer: No
' Version: 1/2020
' Used Libs: Audio, Core, fiddlearound
' Phone,XUI
' ###############################################
' Usage is Roayalty free for Private and commercial
' use only for B4X-Anywhere Board Members.
' ###############################################
Sub Class_Globals
Dim tiD,tiI As Timer
End Sub
'Initializes the object. You can add parameters to this method if needed.
Public Sub Initialize
End Sub
Public Sub beep(DurationMilliseconds As Long)
Dim b As Beeper
b.Initialize(DurationMilliseconds, 500) '300 milliseconds, 500 hz
b.Beep
End Sub
Public Sub Vibrate(DurationMilliseconds As Long)
If DurationMilliseconds <> 90 Then
Dim p As PhoneVibrate
p.Vibrate(DurationMilliseconds)
End If
End Sub
Public Sub beepAndVibrate(DurationMilliseconds As Long)
beep(DurationMilliseconds)
Vibrate(DurationMilliseconds)
End Sub
public Sub Alarm(DurationMilliseconds As Long)
tiD.Initialize("tiD",DurationMilliseconds)
tiI.Initialize("tiI",250)
tiD.Enabled=True
tiI.Enabled=True
End Sub
private Sub tiD_tick
tiI.enabled=False
tiD.Enabled=False
End Sub
private Sub tiI_tick
beep(250)
End Sub