I have read How to detect the default phone number of a contact (if set), but it seems that IS_SUPER_PRIMARY only works on some phones, is there a better solution to get the default number for a contact?
I believe this simply is one of those device dependent things. I'd use IS_SUPER_PRIMARY and when it returns nothing I'd just pick one from the list of numbers or let the user pick which to use. Alternatively you should look into which number from a list the user has used most often and use this as the primary.
Related
Hi allCurrently i am geting is_primary value 1 oly for the contacts which have more than 1 contact. numbers.e.g. Contac Z having phone numbers1. +1-334455662. +1-998822333. +1-33221122I have few questions about the Contacts in android
1. When the is_primary is set to non-zero value?2. Why it is not set to non-zero for the contacts which dont have multiple phone numbers ?e.g. Contact A having contact number lets say +1-22334455.I gone through all the resources available but not got satisfyinh answer.Please helpThank you Cheers
IS_PRIMARY can be set by a SyncAdapter to signal to the system this value has a higher value/priority over other items of the same type (e.g. the main email of the contact compared to the other email addresses on record for that contact).
It can also be set by the user, via the Contacts app, each contacts app behaves a bit differently, but in most case you can long press on a phone number to get a menu pop, in which you can mark the selected phone number as the default (same goes for emails).
Note that you can perform that action even if that contact has only one phone number.
In general it's up to any app that has WRITE_CONTACTS permission to mark a certain data item as IS_PRIMARY, either to sync some primary-state from the cloud, to follow a user manual action like setting a phone as the default, or any other use-case an app might have
I am debugging an application and when the Cursor retrieves a pointer from the database, I see something like this
How can I know what means the value behind #? How can I bind this address to the database value behind it?
Why do I need this? The app is behaving differently on 2 devices with 2 Android systems. I am cross debugging both and would like to know what the cursor returned on each device. For example, the value behind # on another device is a 4-digit integer.
The output is that of Object.toString() and the number part is the hashCode(), not really an address.
For Cursor content debugging, have a look at DatabaseUtils.dumpCursor().
You actually want to look up the SQL query to know what is going on, not this number. Just place you cursor on the Cursor and press Control-F1.
The Android SDK class Build.VERSION gives programmatic access to many (relatively) hard-wired values from the phone, as has been discussed in several other threads. But I am looking for a way to access the "Device name" value the user can enter/change from the About Phone dialog.
When I first went to About Phone on my Galaxy S4, the "Device name" value was SCH-1545, which is the same value as I get if I print out
android.os.Build.MODEL
The phone lets me enter a new value, say, "Foo bar" but, as I rather expected, that did not change the value of android.os.Build.MODEL, even after rebooting the phone. Nor did it change the value of
android.os.Build.USER
which seemed the only other field it might affect.
Is there a way to access the value that the user can change/see?
Actually, it turns out that this question is essentially a duplicate of another question which I was unable to find with my original search terms and I have since up-voted. The short answer is: yes, for some phones but not in the general case, AND you have to request bluetooth permission to use the call that can do it. IOW, ugh, no not really.
I'm leaving this question up in the hope that the terminology I use may help another searcher find the answer more quickly.
That is most probably the device name from Bluetooth.
Use BluetoothAdapter to access the name.
This is an extension to the question here. Now I quote CommonsWare
There is no reliable way to retrieve mobile number of device programatically. The only option remaining and I can think of is getting user to input for the phone number.
My question is how to check if the phone number entered by the user is correct for these and any more possibilities which I cannot think now:
The number entered by the user is of the same device the app has been downloaded on.
User did not make any typographical error while entering the number
User did not enter any local calling code like leading 0
I have spend sufficient time on StackOverflow and web and this is not a duplicate question.
I will appreciate any help, clues or suggestions.
1.The number entered by the user is of the same device the app has been downloaded on.
Again this is something kind of impossible to test, else the Tricky way mentioned by #neteinstein
2.User did not make any typographical error while entering the number
3.User did not enter any local calling code like leading 0
I think you still not aware of this library by google,used for Parsing/formatting/validating phone numbers for all countries/regions of the world.
Using that you can achive your other 2 solutions.I think.
Link : http://code.google.com/p/libphonenumber/
If you are willing to possibly spend some user money you can send an SMS to yourself (number inputted by the user) and check if it arrives.
If it does, the number is correct. If not... either you have no network, or the number is incorrect.
I don't even think the phone has the number visibility, according to my experience with Mobile Operators, only on their side they have that visibility.
Though I do not know about nr1, I think you can solve problem nr 2 and 3 quite easily by analysing the number while its a String. That way you can easily check what characters it contains and what positions these characters are on.
I hope this helps.
Greets,
Wottah
I see there are plenty of examples on how to call a number, and I also see that I can only have it pop up the dialer to go to an emergency number. But in all those example they hard coded "911" as the number to use. well this works fine in the US but since android phones are sold in other countries and thusly there is the possibility that my app will be bought by someone not in the US, or that someone who lives in the us may take their phone overseas; is there a way then my app can realize it's not in the us and thusly has to use a different number to call emergency service and what that number would be?
So to sum up I'd like to know if there is a way I can have it so when the app goes to bring up the dialer with the emergency number for the country it's in, with out having to know that number at complie time?
According to the source for PhoneNumberUtils.isEmergencyNumber():
String numbers = SystemProperties.get("ril.ecclist");
if (TextUtils.isEmpty(numbers)) {
// then read-only ecclist property since old RIL only uses this
numbers = SystemProperties.get("ro.ril.ecclist");
}
numbers will be a comma separated list.