sample contacts:
_ID DISPLAY_NAME PHONE
1 contact1 11111111
2 contact2 22222222

Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI,
Uri.encode("22222222"));
Cursor c = this.getContentResolver().query(uri, new String[]
{Data._ID}, null, null, null);
long profileId = 0;
if (c.moveToFirst())
{
    profileId = c.getLong(0);
}
c.close();
c = null;

final ContentValues values = new ContentValues();

if (profileId > 0) {
    values.put(StatusUpdates.DATA_ID, profileId);
    values.put(StatusUpdates.STATUS, "HELLO WORLD!");
    values.put(StatusUpdates.PROTOCOL, Im.PROTOCOL_CUSTOM);
    values.put(StatusUpdates.CUSTOM_PROTOCOL, CUSTOM_IM_PROTOCOL);
    values.put(StatusUpdates.PRESENCE, 4); //
    values.put(StatusUpdates.STATUS_RES_PACKAGE,
this.getPackageName());
    values.put(StatusUpdates.STATUS_LABEL, R.string.label);

    ArrayList<ContentProviderOperation> ops = new
ArrayList<ContentProviderOperation>();
 
ops.add(ContentProviderOperation.newInsert(StatusUpdates.CONTENT_URI)
            .withValues(values).build());

    try{
 
this.getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
    }
    catch(RemoteException e)
    {Log.e...}
    catch(OperationApplicationException e)
    {Log.e...}
}

I'm trying to insert status to the specified contact "contact2", but
it doesn't work correctly, and always insert to "contact1".

Please help me, many thanks.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to