How to view Contacts Detail Activity - android

I have copied contacts local phonebook and have shown them in my custom list. While copying the contact list i have maintained each contact and his detail in an array.
Now I want to open up the default details screen when i click on any contact in my list. Please tell me how is this possible.

Looking at the Intent.ACTION_VIEW Pass this action with a valid URI.

For anyone whos looking for specifics:
Intent contViewIntent = new Intent(Intent.ACTION_VIEW);
Uri uri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_URI,phn_user.getId());
Where getId return Id in String.

Related

How to send specific id to intent picking contacts

I can pick multi contact data via
Intent phonebookIntent = new Intent("intent.action.INTERACTION_TOPMENU");
phonebookIntent.putExtra("additional", "phone-multi");
phonebookIntent.putExtra("maxRecipientCount", MAX_PICK_CONTACT);
phonebookIntent.putExtra("FromMMS", true);
startActivityForResult(phonebookIntent, REQUEST_CODE_PICK_CONTACT);
but when I want to add another contact to present data , the selected contact data disappears.Is there an intent filter like "selectedList" by which I can send id list to contact picker intent
That could be impossible to do using implicit intent. You can always create your own activity, get the contacts using ContentProvider, pass the parameters you want and handle the logic there.

How to avoid duplicate contact restore in android

I'm doing an android application which does Backup & Restore Phone contacts into remote server as vcf file type.Suppose if I have 5 contacts, I could do Backup it into server well & good. After that If I delete 2 contacts in the mobile,now totally 3. But server has 5 contacts. Then If I restore from server, that 3 Contacts will gets duplicated. Below is my code. How could I avoid that duplication while restore contacts.
Code:
final MimeTypeMap mime = MimeTypeMap.getSingleton();
String tmptype = mime.getMimeTypeFromExtension("vcf");
final File file = new File(Environment.getExternalStorageDirectory().toString()+ "/contacts.vcf");
Intent i = new Intent();
i.setAction(android.content.Intent.ACTION_VIEW);
i.setDataAndType(Uri.fromFile(file), "text/x-vcard");
startActivity(i);
Add your contact in ArrayList < String> arrDupContact and while delete contact remove contact from arrDupContact also.While fetching contact from server check whether it contain that particular contact or not it is contain then bypass it, if not the add it.
I would you Set cont = new HashSet(), becasuse HashSet don`t allow duplicates by default.
Please find this quick summary here:
http://www.codejava.net/java-core/collections/java-collections-framework-summary-table
Please find a massive summary here:
https://docs.oracle.com/javase/8/docs/technotes/guides/collections/overview.html

When user clicks on listview item, open contact list, select contacts, and send sms with listview item data

I'm trying to make an app which the user can store some data in sqlite, which he/she can view later in a listview.
That's the first part of my app.
The second part is when the user clicks on a listviewitem, send via sms the information of that listview item.
How can i acomplish this? Can the user select which contacts he/she wants to send to?
I am sharing you the links i have used to do these things hope its helps
for Storing in database
:http://www.tutorialspoint.com/android/android_sqlite_database.htm
for sending sms:
Intent smsIntent = new Intent(Intent.ACTION_VIEW);
smsIntent.setType("vnd.android-dir/mms-sms");
smsIntent.putExtra("address", "type phone number...");
smsIntent.putExtra("sms_body","your message...");
startActivity(smsIntent);
to achive this on list item click follow this:
http://www.vogella.com/tutorials/AndroidListView/article.html
for user to select more than one contacts use listView with checkbox:
http://www.mysamplecode.com/2012/07/android-listview-checkbox-example.html

How to show the name of the person instead of phone numbers?

Intent myIntent = new Intent(Intent.ACTION_DIAL);
myIntent.setData(Uri.parse("tel:" +CallNumber));
startActivity(myIntent);
Is there any possibilities to show the contact name instead of the phone numbers on selecting menuitem call?
Maybe this link on stackoverflow can help:
Get Contact by Phone number on Android
First use it to retrieve the contact name based on the phone number. Then use:
myIntent.setData(Uri.parse("content://contacts/people/"+PersonName))
to call the person.

Set Contact Number in Contact Uri

In my application i want to add the contact number . So here i called the Below code . It call the Add contact screen but i want to set the contact number using code . can any one help me to solve my problem ?
Intent intent = new Intent(Intent.ACTION_INSERT,People.CONTENT_URI);
startActivityForResult(intent, 1);
It is called Add Contact Screen .
As far as I know INSERT creates an empty contact. Maybe you can create an entry and then call the action.EDIT pointing to he new contact
Here is the Solution.
Intent addContactIntent = new Intent(Contacts.Intents.Insert.ACTION, Contacts.People.CONTENT_URI);
addContactIntent.putExtra(Contacts.Intents.Insert.PHONE,"Phone Number");
startActivity(addContactIntent);

Categories

Resources