开发者

Presence status on custom contacts dissapears after short time

开发者 https://www.devze.com 2023-03-08 05:27 出处:网络
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.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号