Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I launch the 'Add Contact' activity in android

Tags:

android

Can you please tell me how to launch the Add Contact' activity in android? Thank you.

like image 537
hap497 Avatar asked Dec 13 '09 00:12

hap497


People also ask

How do I launch a contact app?

From the Home screen, tap the Contacts icon (in the QuickTap bar). You can also tap the Contacts tab (at the top of the screen) from the Phone app.

What is launch activity android?

Launch mode is an instruction for Android OS which specifies how the activity should be launched. It instructs how any new activity should be associated with the current task.

How can I get call activity in Android?

If you start the activity with startActivityForResult(Intent, int) , then you can get calling activity by getCallingActivity(). getClassName() .


2 Answers

API Level 5 and above solution

// Add listener so your activity gets called back upon completion of action, // in this case with ability to get handle to newly added contact myActivity.addActivityListener(someActivityListener);  Intent intent = new Intent(Intent.ACTION_INSERT); intent.setType(ContactsContract.Contacts.CONTENT_TYPE);  // Just two examples of information you can send to pre-fill out data for the // user.  See android.provider.ContactsContract.Intents.Insert for the complete // list. intent.putExtra(ContactsContract.Intents.Insert.NAME, "some Contact Name"); intent.putExtra(ContactsContract.Intents.Insert.PHONE, "some Phone Number");  // Send with it a unique request code, so when you get called back, you can // check to make sure it is from the intent you launched (ideally should be // some public static final so receiver can check against it) int PICK_CONTACT = 100; myActivity.startActivityForResult(intent, PICK_CONTACT); 
like image 52
zwickilton Avatar answered Oct 12 '22 23:10

zwickilton


These two lines do the trick:

    Intent intent = new Intent(Intent.ACTION_INSERT,                                 ContactsContract.Contacts.CONTENT_URI);     startActivity(intent); 
like image 43
Vikram Gupta Avatar answered Oct 12 '22 22:10

Vikram Gupta