Android Question Doorbell App - how should I start?

MikeSimpson

Member
Licensed User
Longtime User
Hello, I am trying to program a doorbell app. My old Android 2.3.3 phone should act as the push button at the door, connectet via WiFi and trigger multipple Android phones/tabelts in my house, also connected via WiFi, they should only make some ring tone, no comunication like an intercom nessesary.

The "push button door phone" will only show a bell-button and will be always on, all other phone buttons will be covered so that visitors can only push the button and can not mess with the phone otherwise.

The other phones/tablets that should receive the signal and ring when the button at the door is pushed, should also respond when the divice is "sleeping", so this part of the code should be written as service module, I guess.

Can enyone give me a hint please what funktion or method I can use to create this?
 

MikeSimpson

Member
Licensed User
Longtime User
Thank you for your help and fast reply Erel.

I have gone thru your suggestions and because I am very new to b4a, the solution with httpServer and HttpJob is to complicated for me.

Now I am trying of combining your Kiosk example with Skype, so that with a push of a button a Skype call is triggered.

But something is going wrong and I can't figure out how to solve this.
The program is working only one time when I start it, then I can press "Stop", and make a call. After the call it isn't possible to make another call. What am I missing? Here is the code from your Kiosk sample with my changes. I have commented the lines I added. The "KioskService" code I didn't change.

B4X:
#Region Module Attributes
    #FullScreen: False
    #IncludeTitle: True
    #ApplicationLabel: Kiosk App
    #VersionCode: 1
    #VersionName:
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

'Activity module
Sub Process_Globals
    Dim kiosk As Boolean
    kiosk = True
End Sub

Sub Globals
    Dim btnStop As Button
    Dim btnSkype As Button                                        'I added a button for Skype
    Dim mySkype As Skype                                        'Added

End Sub

Sub Activity_Create(FirstTime As Boolean)
    mySkype.Initialize                                            'Added
    btnStop.Initialize("btnStop")
    Activity.AddView(btnStop, 10dip, 10dip, 200dip, 200dip)
    SetButtonText
    btnSkype.Initialize("btnSkype")                                'Added
    Activity.AddView(btnSkype, 10dip, 200dip, 200dip, 200dip)    'Added
    btnSkype.Text = "Door Bell"                                    'Added
End Sub

Sub Activity_Resume
    Log(Activity.GetStartingIntent)
    If kiosk = False Then
        Dim r As Reflector
        r.Target = Activity.GetStartingIntent
        If r.RunMethod2("hasCategory", "android.intent.category.HOME", "java.lang.String") Then
            Activity.Finish
        End If
    End If
End Sub

Sub Activity_Pause (UserClosed As Boolean)
    If kiosk Then StartServiceAt(KioskService, DateTime.Now + 1 * DateTime.TicksPerSecond, False)   
End Sub

Sub btnSkype_Click                                                'Added call to the Skype test server

mySkype.AddParticipant("echo123")   
mySkype.AudioCall(mySkype.ParticipantsList, "Hello There")
   
End Sub

Sub btnStop_Click
    kiosk = Not(kiosk)
    If kiosk = False Then
        CancelScheduledService(KioskService)
        StopService(KioskService)
    End If
    SetButtonText
End Sub
Sub SetButtonText
    If kiosk Then
        btnStop.Text = "Stop"
    Else
        btnStop.Text = "Start"
    End If
End Sub
 
Upvote 0

sirjo66

Well-Known Member
Licensed User
Longtime User
I think that if you don't want to use HttpServer and HttpJob, the best solution is to use a Socket

Sergio
 
Upvote 0

coslad

Well-Known Member
Licensed User
Longtime User
Hi

I am not new of b4a but i don't know anything about http, can you advise any good tutorial about HttpServer and HttpJobut ?
 
Upvote 0

MikeSimpson

Member
Licensed User
Longtime User
I have now modyfied your "Walkie Talkie App" and added it with your "Kiosk App". Everything is looking good. The only thing is, that I can only connect one device to the "DoorBell", but I can live with it. Thank you Erel, you are great.
 
Upvote 0
Top