I am creating a pos application on android.
The database for the app is in the cloud. That causes a problem when the internet is down. To solve that problem i have created a SQLite database that keeps needed information for the work of the people using the app. (the app sync's data with the cloud when possible).
But a new problem arises.
If a client wants to have multiple devices in his establishment, i need these devices to be synced. Meaning the SQLite databases on all the devices need to look the same.
I think i should be using WiFi direct as in WiFi p2p but after some research i am not so sure anymore. All the examples i have seen are file transfer oriented, but i need to transfer simple lists of classes.
This process should happen seamlessly once we set up the devices in the background threads.
Here is how i imagined it.
We have for example 3 devices.
All 3 devices need to have all the SQLite data on them, and another important factor is that i have a fiscalID/orderID that needs to be incremented every time a order or fiscal is printed.
So: We have a primary device, who handles the increment of the number, meaning when a secondary device wants to print a order/fiscal, he asks the main device for the id, once the secondary device gets the id, he inserts the order or fiscal, after that he sends the SQLite data entry to the main device, the main device spreads that data to all other secondary devices.
If WiFi direct is the only solution to this problem, can someone link me to a good tutorial on this topic? It seem's that tutorial's on this topic are scarce, which is a shame because WiFi direct/p2p seems like a interesting concept.
Thanks.
Related
Basically what I would like to do is have two phone in close proximity press a transfer button which will notify a server about both the devices latitude, longitude and unique ID. From here I would like the server to compare the latitude and longitude of both devices to check there within a close proximity of each other. If they are within the accepted proximity range the server will swap the ID's of each device so that they can then retrieve information about each other from a database.
I have been stuck for a while and seen a few options but am unsure about there difficulty of implementation and there capability of performing the required task.
I am using using Android and Firebase and have this mostly done except for the server data analysis as mentioned above. The first idea was to try Firebase Functions as it is simple to integrate with the Firebase database but I have had a hard time finding examples in Typecast to perform the functions I want. The other option I see is to use node js which I know next to nothing about and don't want to invest an unnecessary amount of time into just for it to fail.
I have searched a good amount and haven't managed to find any solutions to fit this criteria so if this question has already been asked and answered please link me to the page.
I know this has already been done by Bump but theirs literally no information available about how there back end worked.
If any of you guys can recommend any solutions to resolve this issue it would be greatly appreciated. If I forgot to mention something or you need more information let know.
Firebase cloud functions + Firebase Database is a good fit to your problem statement.
When the two devices initiate a session, you can create a node(session) on Firebase realtime DB and then have a cloud function listen to changes in a node where the sessions would be created. The Firebase cloud function could then compute the logic about the proximity and swap id's.
Where is that you are stuck?
I want to make an app that takes info/data from other apps that are already installed on my phone ( Android ). By example: Let's say I want to make an app that shows how many messages I sent to each person with my phone. Then I would like to get my app linked with the message app on my phone and count how many times I sent someone a message , get that data, and put it on my app.
When I search for this problem, one 'solution' I found was working with intents, but it's NOT that, by far as I know, you can use intents to share data between apps you created yourself. I want to be able to get data from apps that I did not make. HOW? Thanks already
You can't, otherwise it would be a security issue, think about a bank app... In Android all the apps are fisically separated into different directories.
You can access data only from apps that expose methods, like Intent.
I'm writing an Android app that I would like to eventually port to iOS and Windows Mobile (though I know absolutely nothing about them right now). I'd like my app to be able to find other phones within a certain radius (maybe 20-30 feet) that also have the game installed so that the users can interact with others in their current physical space. Is this possible and, if so, how?
I plan on the app requiring an internet connection so my first thought was to use GPS like described at iOS Find Other Nearby Devices (GPS locations), but that would require continually transmitting data to the server to update the user's location using both bandwidth and battery (not to mention the server resources). GPS also seems to take a while to get any sort of accurate fix, and even though I wouldn't store historical data I wouldn't expect users to trust me with that sort of private information (as well they shouldn't!)
I know there are proprietary technologies, such as Sony's NFC, but that's far too narrow a focus to use for an app that I'd like to be device and OS agnostic. What other options are there? Assuming the user is willing to give the app the appropriate permissions, what other methods could allow one device to find another nearby one, within a 10-15 meter range, that is practical for a large (million+) userbase? Is HTML5 Geolocation a better path? Or is GPS my only real option?
I did find Use Android GPS to detect and connect with other phones, but was hoping the past few years have opened up further options.
UPDATE
Thank you for all the responses so far. To answer some questions posed in the comments and answers, I thought I'd describe how I expect the apps/devices to interact.
All users who install this app will have an agent running in the background to update their current geolocation and to listen for pings. Any user may open the full program and send a quick request for all other users nearby. If I go the central server route, then the server responds to that request with a list of nearby usernames. The user can then pick one of those to initiate a connection, in which case the target device makes a sound to notify of a request to connect.
From there it's easy enough to handle the interaction between two devices. Finding those nearby users is the sticking point for me.
Options I can see
Bluetooth (BT). I don't know, if I'm not too skeptical about it, but I see couple of problems. Short range. The biggest energy consumption. Maximum 7 peers connected at the same time (but maybe it's enough...). The big advantage is that a lot of devices support BT.
BT LE (low energy). Ok, it helps energy consumption problem. But, requires Android 4.3.
WiFi Direct (aka P2P). I gave it a shot, I'm a bit disappointed. The problem is that it needs Android 4.0 or higher. Even worse, some devices don't have required hardware. I launched WiFiDirectDemo from Android samples on Samsung Xperia Miro ST23i. Clicked on "search" and the only thing I got was a toast "enable WiFi P2P - in your settings". I clicked on everything in that settings, there is just normal WiFi and other stuff, no mention about Direct or P2P. Xperio Miro just doesn't support WiFi Direct.
WiFi connection with a server through internet + device geolocation. Server keeps positions of users and answers questions like "who is 20 feet in my range?". The problem can be the precision of geolocation. If the walls are thick or you are in a place on earth with few satellites - it can be very inaccurate.
To sum up
There is greater probability that somebody will have WiFi turned on all the time than BT. BT also have some time limits after which it is turned off (they make it this way to probably save battery). So, WiFi seems a better choice than BT.
If WiFi Direct is popular enough for you - I would give it a try. If not, option number 4 seems the best. It's not ideal, I know, but at this point it's hard to come with something better (we still need technology development, WiFi Direct looks promising).
I would use the central server approach. Each phone sends position data to the server. The server notifies the other users when they are in range. To limit used data, only send positions when the device reports movement more then X meters.
Also, consider using a Ping button. The user presses it to send the position when they wish to find someone nearby. Position data would only be sent on this ping. This would use very little power and provide good privacy.
It might be possible to detect details about the connected Wifi access point. If you could get the AP or Gateway's MAC address, you could send that as a kind of position. All the players on the same Gateway would be close by.
I have an application (however I'm testing using the sample bluetooth chat from the SDK) where two android devices connects each other, and exchange data.
I already have part of the pairing process hardcoded using the BT address, problem is: the dialog it appears to confirm the pin. Is there a way to make that work programmatically? The only thing that "appeared" to solve my problem was in this question, but that API is completely abandoned, has no documentation and many issues.
As fair as I know the problem is that if the device is not the device database with paired devices, without root access the standard API is always going to prompt the user, but I'm still wondering if there's a way.
Bluetooth autopairing is defined only for some devices. To change this you should rewrite Android framework. So, from the application, it seems to me, this is impossible to do.
I'm doing some work for my theses in networking, and have stumbled into a little problem. One of the first steps in the work I must do consists on having a computer working as an AP (I am using hostapd for this) and with it, detect all the devices in the room which currently have wifi turned on (do not need to be associated with any AP).
I have found a thread that pretty much asks the same ( discover mobil devices using wifi ), and I understand the answers that were given, but they don't give any hint as to how this can be done. The post ends saying that the person was able to do this using Kismet, however I can only seem to use Kismet to discover clients already associated with an AP.
Can someone point me in the right direction here please? If not using Kismet, then maybe suggest a different tool that works with Ubuntu.
Ps. I will need to run a continuous scan of the "room" to find any new devices and then send this information to an event manager written in Java.
I guess you could have a WiFi card, in monitor mode, scanning every channel for beacons. On Linux, aircrack-ng is the tool suite you are looking for. airodump-ng is the tool that shows you a list of devices present around your location. It is designed to display first the hotspots with the potentials clients, but also shows all the devices that are connected to an AP or trying to probe to an AP.
However, you won't be able to scan devices having their WiFi connection turned down. I'm not sure about devices not associated to an AP, my guess is you will be able to detect them if they send beacons one way or another (for example, to detect WiFi hotspots).
If you need this in Java, you can write a wrapper to airodump-ng, or you can launch airodump-ng as a service outputing to a file and read this file from a Java app.
No concrete answer I'm afraid, but I hope these will help you figure a way to solve your problem.