Before I go too far and realize there was an easier way to do this, I have a simple question:
Situation: In an Android app, I have 200 hand-picked restaurants and I want to display the 20 closest to a user based on his location. There are multiple users and restaurants should be added dynamically. For this, I need a list of those restaurants. Logically, I should only return the 20 closest ones, in case it grows to 20000 one day. It only makes sense.
Question: Does google provide an API for me to store data that can be accessed from all users based on their own query string? Or do I have to store it in an external server and get the infos with JSON?
Just don't want to miss an available service that makes all of this easier.
Related
Background
I work on an app that among other things, allows to contact with businesses found via Nearby-search, navigate to them, visit their websites...
Once the user performs any action on a single business, it's supposed to be added to the recents-list, allowing the user to do it again, or see the information about the business again.
If the user called some business, next time he visits the recents-list, it should be shown there as a list-item, along with the name, phone number, etc...
Same goes if it was navigated to.
The problem
I've noticed in the terms a very big limitation of caching, saying that only the place-ID is allowed to be store permenantly, and the basic geographic-coordinate (lat-lng) can be stored for 30 days.
Weird thing is that it says it's ok to store only place-ID and coordinate, but I couldn't find what's the use of these if there is no mapping and context whatsover with them. And of course if you add context, you actually do store more information. For example, if you've called the place and showed the name, you already know both, so both should be mapped to the place-ID...
Links:
https://cloud.google.com/maps-platform/terms/maps-service-terms#5.-places-api
Caching. Customer can temporarily cache latitude (lat) and longitude
(lng) values from the Places API for up to 30 consecutive calendar
days, after which Customer must delete the cached latitude and
longitude values. Customer can cache Places API Place ID (place_id)
values
https://cloud.google.com/maps-platform/terms/#3.-license
No Caching. Customer will not cache Google Maps Content except as
expressly permitted under the Maps Service Specific Terms.
https://developers.google.com/places/web-service/policies#pre-fetching,-caching,-or-storage-of-content
Applications using the Places API are bound by the Google Maps
Platform Terms of Service. Section 3.2.3(a) and (b) of the terms
states that you must not pre-fetch, index, store, or cache any Content
except under the limited conditions stated in the terms.
Note that the place ID, used to uniquely identify a place, is exempt
from the caching restriction. You can therefore store place ID values
indefinitely. The place ID is returned in the place_id field in Places
API responses.
What I've found
Sadly I couldn't find more information about this.
What I was told by someone is that caching should be fine for 24 hours as a part of "fair-use" to avoid re-queries of things that you already got, similar to how web browsers handle queries. This can help in case the user wishes to see information he already got just a few seconds ago, for example.
I was also told that if it's local on the user's own device, it should also be fine, as it's not published outside, and as the user could have saved the information anyway, manually.
For each of those claims, I couldn't find a reference.
This is very important here, as there has to be some mapping between the items on the "recents" list of the app and the actual place. For example, if it was a phone call, it has to at least have place-id (of the place) and the phone number (of the call). But it should also show the name of the place, as the user just showed this information and expect to see it there too, instead of just a phone number.
The questions
Weird thing is that it says it's ok to store only place-ID and coordinate, but what's the use of these if there is no mapping whatsover with them? What could I do with this exactly?
What is the fair-use of caching in this case?
Is it true that caching is ok in general for 24 hours, for all APIs ?
Can I also store in storage if it's very relevant as the user did something related to the query (dialed the phone number of the place, so should be possible to see this information right on the list, with other places)? I mean to store basic, relevant information I got from Google Places, for each recent-list-item ? Maybe I could set the basic information with an expired-date, while letting the place-ID stay, and when it's expired, only then to re-query?
Otherwise, it would mean the app will need to re-query all places each time the list is shown, to get a mapping between phone numbers and each place's information, and could easily cost a lot of money.
Using Android Studio, what sort of things are needed when trying to compare a specific user's location to every other user. For example if there are 1000 simultaneous users, and I want to find the closest one(or farthest) to any given user, what sort of calculations need to be done?
If each user's locations were saved to a DB, where do I start? Is it necessary to compare one location against the 1000 (or more) users to find the closest, or would it make more sense to make some type of cut-off (i.e. only compare users who are within 50km).
It seems overwhelming and I am new to android, so I am unsure where to even start. Parse.com and Pubnub are being used in this project.
Geohashing by User Proximity Tutorial
I'll reference for you here the geohashing tutorial that walks you through how to build a realtime app that connects users based on relative location.
Note that this example is written in JavaScript and not Java/Android. However you can still use this design pattern to determine proximity.
App Geo Location: https://www.pubnub.com/blog/2014-05-07-geohashing-chat-by-proximity/
There is also a short video which discusses the Geohasing concept.
Adding in Parse SDK and Location Comparison
Also you can add in this link: Parse reference guide. And a Parse Connector SDK if needed.
Hi everyone i'am currently developing an android game, it uses your phone number when you first use the game(it is for an identification of the user).
It is an social game at some time when the user requests it returns a list of people who are currently online(playing the game),as json array(there phone number,name,photo)and from the data received you need to filter it out and display in two list views. The filtering done by this method:
1)Each element from JSON data(each person)if there phone number is found in user's contact list then is displayed in the first listview
2)if the number is not found in users contact list it is displayed in second listview.
But my doubt is that if the JSON array returns details of 10 people, you need to check for this 10 people whether they are in user's contact list.And does this kind of a technique takes a lot of time and creates delay in the UI..?
If yes please suggest me some other method.
Also please tell me how can I check whether a number is in user's contact list(I make the users upload there number to server without any country code).
So please in the number finding method you need to end the checking one a number has been fully completed.(starting from the end.
eg : 8086934565 (no saved in database) +918086934565(no in contact list)
then we need to start from last so that
5==5 then continue
6==6 then continue
till any of the no (+918086934565 or 8086934565) ends without breaking any equivalent condition.
eg for numbers +918086934565 and 8086933365
checking from the last
5==5,6==6, 5!=3 there the equivalent condition goes wrong and hence it should get out from the loop with a flag ie the numbers are not equal.
Please write me the function to do this or tell me an alternative method.
Any help would be appreciable.
Thanks.
Ugh, that's painful to read...haha...You're suggesting using phone numbers to identify users in a multiplayer matchmaking scenario? That's taboo...If you return a JSON array of users phone numbers, names, and photos, your app will almost certainly be permanently banned from the market and possibly your entire account. That is about the biggest security risk that I can possibly think of, you might as well have a textfield where everybody types in their social security number and it posts it to craigslist. Basically any of your users could just repeatedly initiate games with people and get names photos and phone numbers of 10 random people at a time by capturing the plain text JSON data coming back. If I were you I'd look into the facebook sdk for authentication or Google Play Game Services for multiplayer matchmaking unless the core mechanics of your game rely on phone numbers specifically, in which case by it's very nature is just not going to fly with users. Asking someone to write you a function to do that is most likely never going to happen on stackoverflow. I'm not even going to get into the last part of the question...This has to be a troll attempt...lol
I am working on an android application which can find users nearby.
I need help in design that application.
I am thinking:
1. When I start my application, I use API to find my location.
2. I send that location to my server.
3. server returns a list of other users nearby.
My question is how can the server keeps track of a list of users who are nearby?
Do I create a background service on phone who will report users location periodically?
And the server maintains a list of all users' location?
Is that approach feasible?
You're on the right track. If you are able to geocode or retrieve your current location lat/lon coordinates, there might be a library that can help you out.
My first thought was the Geocoder (https://github.com/alexreisner/geocoder) library for ruby, it offers a slick API that allows you to easily find other nearby objects:
if obj.geocoded?
obj.nearbys(30) # other objects within 30 miles
obj.distance_from([40.714,-100.234]) # distance from arbitrary point to object
obj.bearing_to("Paris, France") # direction from object to arbitrary point
end
There are other options that are easy enough too, if you're using PostgreSQL with PostGIS, you have some utility functions that I'm sure you could use to query 'nearby' users. (Found an example, "What is the best way to find all objects within a radius of another object?" http://postgis.net/docs/manual-1.3/ch03.html#id434832)
So the overall workflow would be:
Request lat/lon from device API
Send lat/lon to server/web service
Use library/database to find other users within a specified radius
Send list of users back down to device
I suspect the most difficult aspect would probably be keeping the lat/lon of other users up to date, but that's a different problem to solve.
Edit:
Just to clarify, you'll definitely want to store all the logged in users' lat/lon inside of some sort of database on the server. It's a very feasible approach, but you'll have to keep it up to date and be able to determine somehow if the data is stale (if that's important to your application). Whether you use a background service to keep that information up to date is kind of up to you and the constraints of the problem you're trying to solve.
The situation: I have many real life locations with specific information associated with them, and updated frequently. I am unsure of how to store this information for use in an android application.
My original thought was storing the data on some server/cloud source/database, reading from the server from each Activity in the app to make sure the info is up to date, and update the server with any changes that may or may not have been made.
For example: there are 200 people inside the library, one person leaves.
So we would read the number of people from the server, display this on the app, person leaves, subtract one, send the new number back to the server.
Would this be an incorrect approach? I'm fairly new to Android in general, and I really have no experience on how to approach this type of situation, what services to use, etc.
I would look into using Parse, its a pretty sweet way to power the backend, and their website is very detailed in explaining how to use it.