I want to disable automatic connection and authentication to saved network and delegate these functions to program, but I didn't find API for this.
Automatic disconnection after connection or trying is not a solution, because client already generate and receive authentication frames, which can be used by badboy for WPA(2)-PSK password recognition.
Also I don't want to save connection parameters for networks in program and erase saved networks in standard wi-fi service.
Please tell me about API or code example for this task.
Related
is there any way to block / close multiple websocket connection from the same browser tab for a client?
I'm creating simple card game using javax.websocket in a backend and pure js in frontend. In the app I'm not going to use any login and password authentication system.
I'm looking for some method where I can close second connection if the client is already connected.
Thanks!
This would work if there was some kind of unique identifier for each player (ie. authorization token).
Otherwise you could check their IPs, whether they are already connected and disconnect them if so. This can be easily bypassed, and there arise issues when there's multiple clients from one router.
I see that there's an onDisconnect() firebase method, however it looks like that method is intended to update other client devices that the current client device has gone offline. For me this isn't very useful. All of our API calls are coming from a central server which handles updates to our other client devices.
Basically, I only have 1 client device communicating with the firebase server... ever. So my question is, when that single device loses connection how will I know? This is probably the most frustrating part of all, Not only do I not know when I lose connection, but I'm still making calls as if each command is successful.
Offline Behavior
Every client sharing a Firebase maintains its own internal version of any active data. When data is updated or saved, it is written to this local version of the Firebase. The Firebase client then synchronizes that data with the Firebase servers and with other clients on a 'best-effort' basis.
As a result, all writes to Firebase will trigger local events immediately, before any data has even been written to the server. This means the app will remain responsive regardless of network latency or Internet connectivity.
Once connectivity is reestablished, we'll receive the appropriate set of events so that the client "catches up" with the current server state, without having to write any custom code.
Take a look at Detecting Connection State in the Firebase Guide. It describes the magic data location /.info/connected that you can monitor for changes in the client's authentication state.
Note: For version 3.0+ see onDisconnect
I have a very basic design of my entire application, where several users with my app on there android devices commits data to the server (I have used REST web services(java) + postgresql as my server) through HTTP post request from the android application. I am successful in achieving this and app runs absolutely fine. Now i want to implement a scenario where any change(CRUD operations) on my db on server should create a notification on my users android device. How should i achieve this with my server design unchanged? I have looked into Google Cloud Messaging, but could figure out the server implementation.
For now i have implemented db triggers on postgresql and able to get control back into java code using Notify/Listen feature of postgresql. From here i need to connect to android device. How can this be achieved. Is Google Cloud Messaging the only way? I have not seen any insert/update statements in there server implementation. Could anyone please guide me on this?
either you can use GCM or implement a Socket at server end and open a socket connection from mobile but this approach may add some additional processing overhead because it will create a daemon thread to listen socket port from mobile device.
You should use native library (NotificationManager etc.), here you can find a great tutorial.
My Advice is for you to use GCM. GCM normally takes a maximum of 4kb, so you could have your own defined "commands". You could use them to determine the requests on both ends, ie on android app and the server end. A php script on the server would help you in this.
I am working on an app where by the android app sends messages to the server via POST and the server forwards the message to the appropriate user via GCM. In my case I have very many things to share so in that case I am using commands, for example if it is a new incoming message I send a GCM to the app with one variable as the command and the rest as the data. On the android app I use the command variable to determine what to do with the data.
Kindly avoid that socket advice, it will have your app drain the battery to sustain the open socket , besides you don't have to re-invent the wheel while Google servers already has it
Is there a way to pair and connect programmatically to a remote device in Hands-Free-Profile (HFP) mode?
So far I am able to just connect to the remote device in the normal way through code. I require to connect to the remote device in the HFP profile mode.
I don't really understand what you are trying to do here.
HFP is a profile, once you have a BT pairing and connection, you can then connect the HFP profile.
HFP itself is not used for pairning.
This is where HFP fits in to the whole of things (from official BT specification HFP_1.6)
There is more information on how to initiate the Service Level Connection in the official documentation
Check page 19
In order to do so you need to implemet the whole Hands Freee communication profile (HFP).
Here you can get the UUIDs for Bluetooth server socket identifiers (you need Handsfree and Handsfree_AG) https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/bluetooth/BluetoothUuid.java
I would also recomend to read blouetooth core specification
https://www.google.co.il/url?sa=t&rct=j&q=&esrc=s&source=web&cd=3&cad=rja&uact=8&ved=0ahUKEwjFs8zr97bPAhXGnRoKHXplDCkQFggoMAI&url=https%3A%2F%2Fwww.bluetooth.org%2Fdocman%2Fhandlers%2Fdownloaddoc.ashx%3Fdoc_id%3D229737&usg=AFQjCNFY1IFeFAAWwimnoaWMsIRZQvPDSw
Here is a specification of HFP that you must implment:
https://www.google.co.il/url?sa=t&rct=j&q=&esrc=s&source=web&cd=2&cad=rja&uact=8&ved=0ahUKEwimg6i597bPAhVMXRoKHRUJA2EQFggiMAE&url=https%3A%2F%2Fwww.bluetooth.org%2Fdocman%2Fhandlers%2FDownloadDoc.ashx%3Fdoc_id%3D292287&usg=AFQjCNHB_Z4ResJYu7IY5ijZADbGB7Telw
I need a tutorial on how to process data on android via wifi. F.e., I need to send some message to PC and receive some other message. How should I establish the connection? What should I do to be able to transfer data and how?
Sorry for the dummy question, but I can't find good manual. I'll be grateful for as detailed manual as possible, or for ome simple example on etablishing wifi connection and sending/receiving simple mesages.
You don't have to use any API for connect to wifi its only requires if you want to manually start your wifi in device,
Just make sure your device has a WiFi enable, and make a simple TCP/IP Socket application. With this you can communication with your system and device, And Use System's public IP to connect with your system.
Also don't forget to give permission Internet in your manifest file..
Here some nice links for Socket Programing in Android..
Simple connection example part II - TCP communication
Networking with Android
Simple communication using java.net.Socket
http://www.anddev.org/tcp_sockets-t276.html
http://www.anddev.org/socket_programming-t325-s30.html
EDIT:: Android WiFi examples,
Scan for Wireless Networks
Using WiFi API
SO Question Android: Is there any way to get notified when known wifi networks get in/out of range?