1

I've tried to use the presence icon and show the presence for my custom users. no matter what i did I've encountered the failed to insert error or the presence was not showing on my contacts.

   values.put(StatusUpdates.DATA_ID, profileId);
   values.put(StatusUpdates.STATUS, user.getStatus());
   values.put(StatusUpdates.PROTOCOL, Im.PROTOCOL_CUSTOM);
   values.put(StatusUpdates.CUSTOM_PROTOCOL, CUSTOM_IM_PROTOCOL);
   values.put(StatusUpdates.IM_ACCOUNT, username);
   values.put(StatusUpdates.IM_HANDLE, user.getuserID());
   values.put(StatusUpdates.STATUS_RES_PACKAGE, context.getPackageName());
   values.put(StatusUpdates.STATUS_ICON, R.drawable.tray_icon);
   values.put(StatusUpdates.STATUS_LABEL, R.string.app_name);
   values.put(StatusUpdates.PRESENCE, StatusUpdates.AVAILABLE);

is there anyone with the solution?

MaTriXy
  • 1,659
  • 1
  • 20
  • 27

2 Answers2

1

For a guide that includes special treatment for 2.2, permissions, etc. see also:

http://www.c99.org/2010/01/23/writing-an-android-sync-provider-part-1

http://www.c99.org/2010/01/23/writing-an-android-sync-provider-part-2

Their source is available:

https://github.com/c99koder/lastfm-android/

Alex Cohn
  • 56,089
  • 9
  • 113
  • 307
0

This line looks suspicious:

values.put(StatusUpdates.DATA_ID, profileId);

What is profileId? If specified, StatusUpdates.DATA_ID should be the _ID of the IM row in the "data" table. You need to have that row before inserting a status.

The common practice is to have a row in the "data" table, then supply IM_PROTOCOL and IM_HANDLE (which is matched against Im.DATA), but leave DATA_ID unspecified in a status update insert. ContactsProvider will match the status to the data row automatically and save you a lookup query.

Also, make sure you use bulkInsert for statuses if you can. That will speed things up a lot.

  • thank you i will try it. profileId is the rawcontact id i'm looking for in raw contacts table. The user was inserted before and now i have a raw contact id that i'm using. apparently not doing it right.... – MaTriXy Apr 16 '12 at 16:46