When is_primary flag set to non-zero value in android contacts? - android

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

Related

Run my python code of kivy app at given time

I have made an basic app when the user selects any random number between 0-99 , and at sharp 8 pm, this app randoo selects one number between 0-99. If the randomly updated number matches with user's selected number then that user is the winner.
I have defined one class, which says that , if time ==8pm then connect to database and check whoever have selected the number which matches to randomly generated number. If there exists any, then update their name to another table.
But the problem is, atleast one user should open my app at sharp 8pm. If no one opens my app at 8pm, then the table won't be updated.
I want my python code to run at Sharp 8pm on Android.
I have heard of AlarmManager ,but don't know how to implement it in Python.
How can I solve this issue?
If there are other methods than AlarmManager also, help me out.
We can do it using Wayscript. Wayscript helps to trigger any python function. Create a python file in way script website and set triggering time exactly at 8pm daily.
This worked for me.

Retrieving default number for contact

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.

Verifying the phone number

In my application first thing the user should do is the registration. For that i need the phone no. So the user will give their 10 digit number. Now i need to verfy the user inputed the same number which holds by the phone. How to do that ? i tried .getLine1Number() but it is returing nothing.
After pressing the register button i am calling a url which will send a verification code to the phone number was inputed by the user. Till that i am showing a alert dialog. After receiving the message only i am dismissing the dialoge box.
So the problem happens when the user give a valid number which may not their number.
PS: I need to get the response through message only.
Only few service providers provide phone number via getLine1Number() method. Instead you can get a unique number for each sim using getSimSerialNumber() method.
Did you set permissions in Manifest READ_PHONE_STATE ?
Method still can return null
Returns the phone number string for line 1, for example, the MSISDN for a GSM phone. Return null if it is unavailable.

android how to get the emergency number to call

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.

How to start an ACTION_PICK activity with only those contacts which have a mobile phone

I want the user to select a contact to which my application would send a SMS. How do I ensure that when I start an activity with ACTION_PICK intent only those contacts with mobile phone numbers are displayed?
Currently, I'm starting the activity like this:
Intent intent = new Intent(Intent.ACTION_PICK, Phones.CONTENT_URI);
You can use:
intent.setType(android.provider.ContactsContract.CommonDataKinds.Phone.CONTENT_TYPE);
However when used the contact picker will display a list of all the phone numbers with the contacts name above each one so if a contact has multiple numbers you will see multiple entries for that contact
I suspect it is not possible. You would need a separate Uri, one that the Phones content provider used to restrict the output to mobile phones only. I do not see that such a Uri exists.
You can still have an activity pick only users with phone numbers, but you will have to write the activity yourself, using a managedQuery().
Reading the code, it looks like you can specify the UI.LIST_CONTACTS_WITH_PHONES_ACTION action in the intent to show only contacts with phone numbers. I haven't tried this out though. Also, this action has the same effect as the contact setting "Only contacts with phones"

Categories

Resources