Retrieve Email Id from contacts

by Deepak » Thu, 19 Jun 2008 13:49:15 GMT


Sponsored Links
 ello All,

Does anyone know how to retrieve email ids from added contacts.

I was able to add email ids programmatically using the following code
snippet below, but I could not retrieve it ! :(

try {
ContentValues person = new ContentValues();
person.put(Contacts.People.NAME, "Smith John,
Mr.");
person.put(Contacts.People.COMPANY, "Test
Company");
person.put(Contacts.People.NOTES, "eNotes");

Uri newPerson =
PhoneBook.this.getContentResolver().insert(
Contacts.People.CONTENT_URI,
person);

if (newPerson != null) {
List pathList =
newPerson.getPathSegments();
String pathLeaf = (String) pathList
.get(pathList.size() -
1);

// add mobile phone number
ContentValues number = new
ContentValues();
number.put(Contacts.Phones.PERSON_ID,
pathLeaf);
number.put(Contacts.Phones.NUMBER,
"(408) 111-1111");
number.put(Contacts.Phones.TYPE,

Contacts.Phones.MOBILE_TYPE);
Uri phoneUpdate =
PhoneBook.this.getContentResolver()

.insert(Contacts.Phones.CONTENT_URI, number);
if (phoneUpdate == null) {
throw new Exception(
"Failed to
insert mobile phone number");
}

// add fax number
number = new ContentValues();
number.put(Contacts.Phones.PERSON_ID,
pathLeaf);
number.put(Contacts.Phones.NUMBER,
"(408) 111-1111-1");
number.put(Contacts.Phones.TYPE,

Contacts.Phones.WORK_FAX_TYPE);
phoneUpdate =
PhoneBook.this.getContentResolver().insert(

Contacts.Phones.CONTENT_URI, number);
if (phoneUpdate == null) {
throw new Exception("Failed to
insert work fax number");
}

// add email
ContentValues email = new
ContentValues();

email.put(Contacts.ContactMethods.PERSON_ID, pathLeaf);
email.put(Contacts.ContactMethods.KIND,

Contacts.ContactMethods.EMAIL_KIND);
email.put(Contacts.ContactMeth



Retrieve Email Id from contacts

by Deepak » Fri, 20 Jun 2008 01:25:16 GMT


 ah ! I actually found the solution ! :)


On Jun 19, 6:48pm, Deepak <[EMAIL PROTECTED]> wrote:
--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Retrieve Email Id from contacts

by Kumar app » Fri, 20 Jun 2008 05:55:34 GMT


 ould you please share to the community...


On Fri, Jun 20, 2008 at 6:55 AM, Deepak <[EMAIL PROTECTED]> wrote:



--
--
Adios,
kokki a.k.a Kumar.A.P.P
Http://sapped.wordpress.com

--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. Unable to receive intent on sending SMS

I want to receive an intent describing the status whether SMS sent or
failed. I have following code to send SMS:

/**
 * MainActivity is my activity class, MessageAlertReceiver is a
broadcast Receiver registered through manifest
 */
Intent intent = new Intent(MainActivity.this,
org.me.androidtest.MessageAlertReceiver.class);
PendingIntent sentntent = PendingIntent.getBroadcast
(MainActivity.this, 0, intent, 0);
SmsManager manager = SmsManager.getDefault();
manager.sendTextMessage("5556", null, "Android SMS Test", sentIntent,
null);


MessageAlertReceiver class is as follows:

public class MessageAlertReceiver extends BroadcastReceiver{

    @Override
    public void onReceive(Context arg0, Intent arg1) {
        Log.i("MessageAlertReceiver","message recieved");
        Toast.makeText(arg0, "I am message",
                    Toast.LENGTH_SHORT).show();
    }

}

I registered this receiver in Manifest file as shown below:
<receiver android:name="org.me.androidtest.MesssageAlertReceiver"
android:enabled="true" android:label="Message status notifier"
android:process=":remote"></receiver>

Message is successfully sent and received on emulator "5556" but no
intent is received to BroadcastReceiver.
Any help????


--~--~---------~--~----~------------~-------~--~----~

2. startActivity from subclass - strange problem

Hey,

I have a Activity and I have a class which extends this Activity. In
this subclass I call:

startActivity(new Intent(this, CameraView.class))

Which should start the "CameraView" Activity. However, I always get
this error:

ERROR/AndroidRuntime(876): java.lang.NullPointerException
ERROR/AndroidRuntime(876):     at
android.content.ContextWrapper.getPackageName(ContextWrapper.java:119)
ERROR/AndroidRuntime(876):     at android.content.ComponentName.<init>
(ComponentName.java:74)
ERROR/AndroidRuntime(876):     at android.content.Intent.<init>
(Intent.java:2093)

If it makes any difference the subclass creates a ListView and when a
row of the ListView is clicked it calls startActivity();

Any help is appreciated! Thanks




--~--~---------~--~----~------------~-------~--~----~

3. got problem while playing video in SDK 1.5 pre

4. Indication bar is just closed upon tapping the downloading item.

5. dialog is getting dismissed when I am flipping the device

6. Sharukh khan , kareena kapoor , shushmeta sen on Magazine cover

7. Sms Competition + 10 Tips On How To Get Rich Fast