This question already has an answer here:
Query for nearby locations
(1 answer)
Closed 2 years ago.
I linked firebase realtime database with my app and added login with email. I want to be able to see other users that are nearby(about 1 km). My original idea was to get my own location based on latitude and longitude and send it to firebase. Then when I log in I would scan all user's location and compare it to mine to show only those around me. It seems to me like a very bad idea to do it this way. My concerns are I would need to scan a lot of users and having all their location data in the app seems like a high security issue. I need a better way to do this. Any suggestions please?
Maybe store each person location in "chunks" that are about 2km x 2km in size.
When a client need to see other users nearby, send him the location of users in his chunk + adjacents chunks and let the client do the final math to determine if they are in the 1km radius.
To avoid security issues, limit the number of chunks a client can request per minute/hour/day.
Related
I am developing an app which will give you nearby Mosques within 10 km of your current location. Now that the Places API allows a certain number of queries per day, I have used firebase to store nearby Mosques for a certain location and I first check if the data is in database or not before querying. But this still doesn't solve the problem. e.g. if a user is on the go the whole day then the results must be changing every single minute, according to his/her location. How can I achieve the desirable results?
As mentioned earlier, I am saving nearby locations in a database with their relative location (around which they exist). But this doesn't quite solve the problem.
Any help will be greatly appreciated.
Places API is a commercial offering - you are meant to pay for using it, if you want to make applications around it.
There's a certain small number of calls that you can do for free, but this is only meant as testing grounds or private use. I am no lawyer, but I would guess that circumventing the fee by scraping the map (like setting a bot to go around a country to build a database of points of interests) would be illegal and would probably get you a letter from Google saying you should stop.
Use AutocompleteSessionToken class to generate a token and place it after your key , this token will reduce your usage because you can request the places api multiple times and still it will be considered as a single request. i hope this will help cause i didnt get your question very well. here is sample of the link:
https://maps.googleapis.com/maps/api/place/autocomplete/json?input=1600+Amphitheatre&key=&sessiontoken=1234567890.
For more details.see here
I'm working on a Android app which have feature of nearby friends. So each user have list of friends stored in a Firebase real time database. Also their locations are saved there while they are moving around.
What I want to do?
I want to compare all the user freinds locations with the user location. And if the distance between the user and his friend is one km or less then the nearby friends list will be updated. This check will be done for reach friend for the user that is using the app.
What I tried to?
Before posting this question I searched around and found one answer on Stack Overflow. But I don't get the function which calculates the distance because the variables names are short and not self explanatory.
Based on the written above does anyone knew how can I calculate distance between two location or can summarize what the functions does which is shown on the link above.
You can use distanceBetween() method from the Location class.
firstLocation.distanceTo(secondLocation)
you will get distance from second location to first one in meters.
I'm currently developing an android app for a weight scale I received that transmits data through bluetooth low energy.
I was looking at documentation and if I got the information correctly, there are specific UUIDs for data. I received a BLE scale with a Chinese protocol document found here: http://www.anj.fyi/protocol.pdf
I found and was able to get a functioning scanner working that lists the device name and the UUIDs it broadcasts.
Lets say I want just the weight data to show up in the UI, nothing else and nothing more.
I don't know what UUID they used for the weight data, and there are a lot of UUIDs. Probably 20+. I checked a UUID compilation and the usual weight data UUID does not show up.
How do I get the data from those UUIDs?
I'm thinking it might be the ones that are notifications, indications or read properties.
Looking at the UUID for example, f000ffc2.
How would I get data from that characteristic? Would anyone have an example code to grab the data from those UUIDs, or tutorials because I'm terribly lost right now.
I really appreciate it.
There are no weight information on the document you list http://www.anj.fyi/protocol.pdf, it is only shows the BLE module hardware interface spec, i.e. it does not specify the detailed service and characteristic.(I an a native Chinese speaker).
Regarding to the UUID you want to know which is the one to represent the weight, yes you are right it should be the read/notification feature without write permission. Can you use the apps e.g. lightblue on iOS to receive the notification(meanwhile change the value on your device) to test it? this will help you to understand which characteristic is the one you want.
This question already has answers here:
How to detect walking with Android accelerometer
(5 answers)
Closed 6 years ago.
I am trying to figure out which google API can be used in order to detect whether the user is walking or just standing. Is there any API that requires only sensor values and not GPS?
I'd use step counter if available and fused location otherwise.
Step counter is lightest to use and consume less battery in comparison to fused location.
Even more, step counter allows indoor discovering.
Fused location might be not enough inside buildings and you'd probably have to use another solution like beacons. It gets more complicated here.
You must use FusedLocationProviderApi in Android to get location of device and then fetch speed on the Location object.
If the speed is greater than 0, then you can say user is moving. The speed is in meter/second.
Refer Android Documentation to understand code : https://developers.google.com/android/reference/com/google/android/gms/location/FusedLocationProviderApi
How do mobile apps like yelp and gasbuddy find a list of nearby restaurants/gas stations? I am creating an Android app and have a list of locations in my database. I want to give the user all the nearby locations from my database based on the user's current location. What is the best way to go about it? I am using Java.
Some databases actually have this built in; for example here's a StackOverflow question about spatial queries in Postgres, which should set you on the right path. Your app would send coordinates to a server, which would use those coordinates to query a postgres database directly.
This link may be helpful http://www.dreamincode.net/forums/topic/92885-distance-between-2-points/
when you get the distance just compre it with if or whatever you want and then show it or save.