How can I launch the 'Add Contact' activity in android
This post may help you out or at least point you in the right direction.
Hope this helps.
Update 05/11/2015:
Per the comments, check out vickey's answer below for the appropriate solution.
How to use intent to launch Add Contact activity?
Intent intent = new Intent(
ContactsContract.Intents.SHOW_OR_CREATE_CONTACT,
Uri.parse("tel:" + phoneNumber));
intent.putExtra(ContactsContract.Intents.EXTRA_FORCE_CREATE, true);
startActivity(intent);
Launch Contacts Activity through Intent
You should add READ_CONTACT
permission in AndroidManifest.
Intent intent = new Intent(Intent.ACTION_PICK);
intent.setType(ContactsContract.Contacts.CONTENT_TYPE);
startActivityForResult(intent, 10011);
How to launch contact detail activity of directory contact in android
This is tricky, but managed to get it working
You need to get the contact's LOOKUP_KEY
, build a LookupUri
from it, append the DIRECTORY_PARAM_KEY
to the LookupUri
, and put that in the intent's setData
.
String name = "hello";
String directoryId = "5"
Uri uri = Contacts.CONTENT_FILTER_URI.buildUpon().appendPath(name).appendQueryParameter(ContactsContract.DIRECTORY_PARAM_KEY, directoryId).build();
String[] projection = new String[]{Contacts._ID, Contacts.DISPLAY_NAME, Contacts.LOOKUP_KEY};
Cursor cur = getContentResolver().query(uri, projection, null, null, null);
DatabaseUtils.dumpCursor(cur); // debug
// add some safety checks first obviously...
cur.moveToFirst();
String lookup = cur.getString(2);
Uri lookupUri = Contacts.getLookupUri(cur.getLong(0), lookup).buildUpon().appendQueryParameter(ContactsContract.DIRECTORY_PARAM_KEY, directoryId).build();
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(lookupUri);
startActivity(intent);
Insert a new contact intent
Finally found a solution, I'm sharing it with you.
That's only a fix for Android version above 4.0.3 and sup. It doesn't work on 4.0 to 4.0.2.
i = new Intent(Intent.ACTION_INSERT);
i.setType(Contacts.CONTENT_TYPE);
if (Integer.valueOf(Build.VERSION.SDK) > 14)
i.putExtra("finishActivityOnSaveCompleted", true); // Fix for 4.0.3 +
startActivityForResult(i, PICK_CONTACT_REQUEST);
Related Topics
How to Retrieve HTML Content from Webview (As a String)
How to Get the Current Dns Servers for Android
Android Test Code Coverage with Jacoco Gradle Plugin
Setsupportactionbar Toolbar Cannot Be Applied to (Android.Widget.Toolbar) Error
After Update of as to 1.0, Getting "Method Id Not in [0, 0Xffff]: 65536" Error in Project
Httpclient on Android:Nohttpresponseexception Through Umts/3G
Firebase Dynamic Link Not Opening the App
How to Pass Arraylist<Hashmap<String, String>>From One Activity to Another
Auto Start Application After Boot Completed in Android
Data Directory Has No Read/Write Permission in Android
Delete File from Internal Storage
Can't Handle Both Click and Touch Events Simultaneously
Android/Eclipse Panic: Could Not Open
Start Google Hangout from Intent in New Hangouts Android App
Error When Using Any Android Design Support Library Elements