Unique Contacts by phone number android - contacts

How to filter contacts by mobile number like chat applications. If a mobile number saved in contacts database with twice by with country code and without country code. I need to merge two numbers as single contact.
For example,
I saved a contact Bala with 9876543210 and +919876543210. In this scenario i need to filter both numbers and return +919876543210 number to my app database.

You need to convert all phone numbers to E164 format (with country code, no spaces or dashes)
e.g: +12125551234
If you're targeting API level 21 and above, you can simply do:
String e164 = PhoneNumberUtils.formatNumberToE164(originalNumber, countryCode);
To get the country code, try this:
TelephonyManager telephony = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
String countryCode = telephony.getSimCountryIso().toUpperCase();
If you're targeting api level below 21, you can use google' libphonenumber library for Android with a similar API.
If all phones are normalized into E164 format, you can remove duplicates by simply not adding a new phone to a contact in case that contact already has that phone (you might find HashMap useful for this)

Related

How to get country code from country name

I want to get the country code by passing in the country name.
For example I have the country Canada, I want to get the country code CA.
I need this conversion because I want to use a country flag flutter package that gets the flag based on the passed in country code.
I know I can hard code a map that will do this conversion for me but I am looking for something simpler
If you are allowed to, maybe you can parse the json from a metadata tool, like DataHub? CSV.

Get state and country with suburb data

So I am trying to download from openstreetmap the list of suburbs in Australia. However I am noticing that they don't seem to store the data in away that would be classified as search friendly.
for example the properties part if the following suburb only includes the local_name, it does not include the state - technically it does by referring to ref:psma:loc_pid
Howeever it's not search friendly because no one is going to search loc_pid numbers - Also it would require another database with loc_pid matches, which I don't see as helpful.
"properties":{"osm_id":-11690275,"boundary":"administrative","admin_level":10,"parents":"-11690291,-2316598,-80500","name":"Kimbolton","local_name":"Kimbolton","name_en":null,"all_tags":{"name":"Kimbolton","place":"locality","boundary":"administrative","way_area":"0.585159","wikidata":"Q55772085","admin_level":"10","ref:psma:loc_pid":"WA1703"}}}
So how can I get boundary information with State and Country codes.

Find data near to user location with split data in Xcode

I'm trying to figure out how i can find data (from JSON) near to the users location on iPhone.
My input consists out of 2 parts, so in order to get to the city and address, I have to get an ID from the province where the user is located.
Province (with ID to go to all Json data of the province)
Data
(Every piece of data has a name, city, address, ...)
Is it possible to find the province where the user is located. Then pass its ID to search the list of data for near to the user located events by reversing all the addresses and cities into coordinates,...?
I'm pretty new to location based programming! Any help is appreciated!
Thank you very much!
The first thing you'll want to do is add CoreLocation to your app. This tutorial shows you how to do that. This will give you the latitude and longitude of your current location.
The next thing you'll want to do is reverse geocode your coordinates. One common API for this is the Google Geocoding API. That will give you your province name.

iphone version of Android contacts attributes?

I'm looking for a way to query contacts in my iPhone app based on a few things. First I only want contacts that have a phonenumber. Second, id like to sort the contacts in order of the number of times contacted.
Android provides attributes that makes this possible and easy to do.
I can't really say that I know the answer, but I believe I know where to find the answer:
http://developer.apple.com/library/ios/#documentation/ContactData/Conceptual/AddressBookProgrammingGuideforiPhone/Introduction.html#//apple_ref/doc/uid/TP40007744-CH1-SW1
Here are some quotes from that document that seems relevant:
There are two ways to find a person record in the Address Book database: by name, using the function ABAddressBookCopyPeopleWithName, and by record identifier, using the function ABAddressBookGetPersonWithRecordID. To accomplish other kinds of searches, use the function ABAddressBookCopyArrayOfAllPeople and then filter the results using the NSArray method filteredArrayUsingPredicate:.
To sort an array of people, use the function CFArraySortValues with the function ABPersonComparePeopleByName as the comparator and a context of the type ABPersonSortOrdering. The user’s desired sort order, as returned by ABPersonGetSortOrdering, is generally the preferred context.
Those quotes were both found on this page. I hope it helps.

"sex" field in Users.getInfo in Facebook API

This is a noob question. According to Facebook API documentation, the sex field in Users.getInfo() function returns values based on users' locale. Hence, determine the gender of user is difficult.
Any solution suggested?
1) This isn't an elegant solution, and perhaps there's a better way that uses the API, but what if you manually created a look-up table for different values of 'sex' in different locales? You could try checking out facebook profiles of people from different countries and get the string displayed for their sex. Then, put that into some kind of dictionary data structure that allows you to grab the M-F string pair based on the locale's code (also given by getInfo()). For example en-US => (male, female), ja-JP => (男性, 女性). Of course, you could try using google translate too. After you gathered this data for a handful of the main locales, you'd be more-or-less covered. Maybe someone on the internets already has done it.
Of course, you could try emailing someone who works on the API for these values. The list of locale codes is here http://wiki.developers.facebook.com/index.php/Facebook_Locales .
2) Here is probably a better solution than (1). If you directly query the FQL User table, the value returned in 'sex' will always be English, starting from February 7 2010. More information about that is here: http://wiki.developers.facebook.com/index.php/User_%28FQL%29 . So, perhaps in the future getInfo() will return only English too. Who knows.
3) The answer to your question is also given on this existing post: Facebook FQL user table `sex` field : how to return male/female even the user is using different locale?