I made my own SyncAdatper
to add contacts of my app to contacts on the phone.
Everything is working now (picture, status, custom action, etc) except for presence status.
According to google:
Since presence status is inherently volatile, the content provider may choose not to store this field in long-term storage.
So, I dont know how to keep the presence on the contacts all the time. The code for updating the presence inside the cursor is开发者_开发问答
ContentProviderOperation.Builder builder = ContentProviderOperation.newInsert(ContactsContract.StatusUpdates.CONTENT_URI);
builder.withValue(ContactsContract.StatusUpdates.DATA_ID, c.getLong(1));
builder.withValue(ContactsContract.StatusUpdates.STATUS, status);
builder.withValue(ContactsContract.StatusUpdates.STATUS_RES_PACKAGE, "ar.com.indiesoftware.ps3trophies");
builder.withValue(ContactsContract.StatusUpdates.STATUS_LABEL, R.string.app_name);
builder.withValue(ContactsContract.StatusUpdates.STATUS_ICON, R.drawable.alltrophies);
builder.withValue(ContactsContract.StatusUpdates.PROTOCOL, Im.PROTOCOL_CUSTOM);
builder.withValue(ContactsContract.StatusUpdates.CUSTOM_PROTOCOL, "PS3SyncAdapter");
builder.withValue(ContactsContract.StatusUpdates.IM_ACCOUNT, username);
builder.withValue(ContactsContract.StatusUpdates.IM_HANDLE, username);
builder.withValue(ContactsContract.StatusUpdates.PRESENCE, ContactsContract.StatusUpdates.AVAILABLE);
builder.withValue(ContactsContract.StatusUpdates.STATUS_TIMESTAMP, System.currentTimeMillis());
operationList.add(builder.build());
The green dot appears but If I leave the contacts screen and return in a short period of times (seconds), "sometimes" the green dot is not there anymore.
Is there something I can do to solve this?
My guess is that when your application is stopped by the OS, it is no longer pushing a presence status.
精彩评论