Is there any open source telephone directory application for Android or how can I make one myself?
+1
A:
Hi, you can use the directory of the device. With this class you can retrieve the contacts of the telephone :
public class Repository extends Activity { /** Called when the activity is first created. */ private static final int PICK_CONTACT = 0; Intent intent = new Intent(Intent.ACTION_PICK, People.CONTENT_URI); /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.Repo); startActivityForResult(intent, PICK_CONTACT); } }
Don't forget to add a permission in the Manifest :
uses-permission android:name="android.permission.READ_CONTACTS"
I hope this will help you.
Michaël
Michaël
2009-10-14 14:30:32
Thanks! I tried the example in http://stackoverflow.com/questions/866769/how-to-call-android-contacts-list . On emulator, is there some test database that I can use to test the code or do I have to built a new database to output names and phone numbers. I haven't used databases in Android before.
Jaska
2009-10-15 12:23:41
You just have to add new phone numbers in the contacts of the phone (emulator).
Michaël
2009-10-15 15:34:16