Android Question Websocket Browser To Device

u2005k

Member
Licensed User
Longtime User
Hi,

I would like to connect to Android using websocket from browser. Need for this is as follows:

I have CRM Web application, when user selects a particular customer, we show all details of selected customer. Customer has contact details like Office Phone, Mobile Phone etc. I would like to call customer from Android phone when user clicks on phone number.

I thought that I will use Websocket from browser Javascript, connect to phone app which is listening on some port and supports websocket protocol. Once it is connected, it will send phone number to Android app. App will receive it and launch Phone app & pass number. So user does not have to enter customer phone number.

I looked at Websocket library but it looks like it is Client library and it will connect to Websocket compatible server.

Is it possible? I also looked at Network library and tried it but from Javascript it gives error during handshake.

Another approach I can take is to use HttpServer Library. Please suggest best method to develop this app.

Thanks & regards...
Uday
 

u2005k

Member
Licensed User
Longtime User
Hi Erel,

Thanks a lot, I used HttpServer library and it worked the way I wanted it.

So from my browser, by clicking on a link, I communicate with server (running on device) and it calls the number directly.

Once again thanks a lot.

Regards...
Uday
 
Upvote 0

u2005k

Member
Licensed User
Longtime User
Hi Erel,

Is it also possible to communicate back to browser when there is incoming call? I can probably use PhoneEvents to detect incoming calls & number. Now how do I pass it to browser/javascript?

Thanks & regards...
Uday
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
This is indeed much more suitable for websockets. However the Android library doesn't support websockets.

There are two options:
1. Create a polling solution. If I remember correctly the chat example uses such a solution.
2. Use an external B4J server. The Android and the browser can connect to it with WebSockets and communicate with each other.
 
Upvote 0
Top