5

I want is to hide all contacts without phone numbers in phonebook from my application.. Just like phonebook do, When you go to phonebook -> settings there is a checkbox which states that "Contacts with phone number only" I want to implement this feature in my app

I need a method (code) to navigate users to phonebook -> settings (activity) (System app)

from my application activity.

or worse case hide all contacts without phone number through database. So that phonebook can filter out.

Currently i found

Intent intent = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI);
startActivityForResult(intent, 123);

Above code opens phone book but i want to open phone book -> settings page.

In sum i want to make phonebook contents "contacts with phone numbers" from my application

Amir Qayyum Khan
  • 473
  • 2
  • 15
  • if I understood your question, this might help you [Android contacts Display Name and Phone Number(s) in single database query?][1] [1]: http://stackoverflow.com/questions/6587674/android-contacts-display-name-and-phone-numbers-in-single-database-query – eeadev Mar 17 '13 at 09:34
  • No, I want to open phonebook -> setting page from my activity, If it is not possible then implement "Contacts with phone numbers only" setting for phone book inside my application – Amir Qayyum Khan Mar 17 '13 at 09:47

3 Answers3

4

I need a method (code) to navigate users to phonebook -> settings (activity) (System app)

There are hundreds, perhaps thousands, of Android phones. None will necessarily be the same with respect to their "phonebook" app. None of those "phonebook" apps necessarily have the feature you seek -- some may, some many not. And, most likely, none have a documented and supported Intent structure for getting to a screen within the app to control the setting that they may or may not have.

I want is to hide all contacts without phone numbers in phonebook from my application

Then you will need to not use the "phonebook" app, but instead display contacts yourself, via the READ_CONTACTS permission and the ContactsContract ContentProvider.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • You mean Phonebook applications are not same in all device? Each android device has its no phoneBook (Nothing stander , activities name etc). Second thing contacts with phone numbers only is filter implement by phonebook.. we can not do this thing with Contact database – Amir Qayyum Khan Mar 19 '13 at 07:31
  • @AmirQayyumKhan: "You mean Phonebook applications are not same in all device?" -- device manufacturers can and do replace the Contacts app from the Android open source project with their own. "we can not do this thing with Contact database" -- why not? – CommonsWare Mar 19 '13 at 11:25
1
Intent intent = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI);
startActivityForResult(intent, PICK_CONTACT);
eeadev
  • 3,662
  • 8
  • 47
  • 100
  • 1
    you just copied my own script! did you go through my problem? – Amir Qayyum Khan Mar 17 '13 at 15:13
  • of course not, Amir. I searched on google and the code snippet is different as well. If it does not solve your problem please trying and explain in a different way. – eeadev Mar 17 '13 at 16:31
  • 1
    No this code does not work .. in your code `startActivityForResult(intent, PICK_CONTACT); PICK_CONTACT ` is a constant such as 123 – Amir Qayyum Khan Mar 18 '13 at 05:28
  • All i want is to hide all contacts without phone numbers in phonebook through my application.. Just like phonebook do it when you go to settings there is a checkbox which states that "Contacts with phone number only" I want to implement this feature in my app – Amir Qayyum Khan Mar 18 '13 at 05:30
0

Well, I have sucessfully developed a Contacts application for Android as my major project. I believe this is quite simple. Here is code how I did it.

Cursor c = getContentResolver().query(ContactsContract.Contacts.CONTENT_URI,
                                           null,
                                           ContactsContract.Contacts.HAS_PHONE_NUMBER + " = 1", 
                                           null, 
                                           ContactsContract.Contacts.DISPLAY_NAME+" COLLATE LOCALIZED ASC");

            mAdapter = new MyAdapter(this,
                       R.layout.single_cell,
                       c, 
                       new String[]{ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME},
                       new int[]{R.id.disp_name},
                       CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);

            listview.setAdapter(mAdapter);

And, in MyAdapter, I have extended SimpleCursorAdapter and over rided bindView() to take advantage of efficiency of SimpleCursorAdapter. However, you need a permission to read contacts. In your android-manifest file. Please mention,

<uses-permission android:name="android.permission.READ_CONTACTS"/>

Hope, it helps.

Gaurav
  • 3,614
  • 3
  • 30
  • 51