Function to find whether the number is contact list android - android

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

Related

For Google places API, what are the "fair use" cases of caching?

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.

Firebase Android - how to add value into DB only if condition is met?

I'm writing a simple app in which users can enroll for a specific course, but only when there is enough place.
So a course would have a list of participants and a maximum participants number. The code that updates the participants list should do that only if the current participants list size is less than the max participants number. I'm going to disable the UI, if the list gets full an no more people can enroll, but still there will be some rare cases when it doesn't update fast enough and people would still click and enroll themselves. So I guess there should be some kind of a check on the database side? How can I achieve a behavior like this in Firebase?

LIKE autocompletion too stressful on the database?

I'm writing an android application that has a search feature that needs to autocomplete from a list of stores. This list will only have up to a few thousand stores in it.
My current methodology is to send a LIKE query to the database every few hundred ms after the user has stopped typing and to populate the autocomplete list with these results.
Would using this method be stressful to the database?
It has been suggested to me that this wouldn't work because making continuous calls would be poor for users with a slow connection and that I should load all the stores into memory and filter from there.
At my work I ran into a similar problem a few months back. The contents of a text box filled by the user were supposed to filter their available options to choose from in a list of strings. The list needed to be updated every time the user typed a key so database calls to fetch records that matched their text were being made several times a second.
This ended up being wayy to slow to update as someone was typing, and this was only with several thousand records and with a server that was being accessed on site.
If you want to update as quickly as someone can type, making that many database calls simply won't do. Users will get pretty antsy having to let their phone buffer to type in some text.
In Short: Make one databse call and load it up onto the phone, and run your filter algorithm from there.
Regularly syncing the list of stores from your back end to the user's device and implementing autocomplete locally is the best way to go.
The JobScheduler API provides a flexible way to set constraints on your background syncing processes.

Get Top Contacted data in android

I am trying to get the top contacted call log details in android. Say if the person A has been contacted for 5 times, B has been contacted for 3 times and C 10 times. Now, I want to extract C and A as my top contacted persons in my phone.
Can any body explain me how to do this. I am able to get most recent call logs now.
I referred this, but no luck
How to get contacts with which the user talks often?
I was able to do something similar in a different approach. In the Contacts API, there is a field called ContactsContract.Contacts.TIMES_CONTACTED which tells the number of times that contact has been contacted.
This approach is not related to the CallLogs API. User can clear the CallLogs, but not the times contacted.
Check this link for developer notes on ContactsContract.Contacts.
Check this link for an android library that I have created which can give you this implementation.ae-apps-library You would be looking for the class ContactManager. Once you fetch all the contacts, you need to sort based on the times contacted field to get your required list.
Edit: If you see the fetchAllContacts method in the ContactManager from the library, you can see how the data are read using the API. All you need to do would be to sort this list based on the timesContacted field by writing a Custom Comparator and sorting the list using that.

Getting the name info of unknown phone number

Let's say we have got a number.We want to send SMS to this number but in the message body we want the user name.ie. "dear name surname". I searched the internet but could not find any code sample.Is not it possible in android?
That's a big problem, is it not ?
Many a times we get calls from phone nos, not in our phone contact list. Those numbers come as unknown numbers. Sometimes the nos, come as masked as well.
So if you are to develop an app to unmask those, how will you get around it ?
Well the solution is you gotta make use of trap calling web sites .
What are trap calling web sites ?
These are web sites , which do a reverse look up of the no that you query and it gives you the name of that number holder.
For e.g, if you are a person in US, then you can make use of the WhoIsThisPhone web site to find out the name of the person calling you.
In case, it's a masked no, you can get around that one too . But you will have to you to pay a subscription fee on a monthly basis for availing this feature(services like trap call are available as apps itself ) .
Depending on which country you are in, you will have to make use of similar services/web sites available to get your job done .

Categories

Resources