我正在Android上開發IM應用程序。目標是具有多帳戶和協議兼容性。 我正在尋找一種獲得Android上聯繫人最佳狀態的方法。 我有一個支持的帳戶類型列表。我有一個功能需要很長時間(contact_id
),並且必須返回最佳的Account
+最佳聯繫方式(例如[email protected]
)。Android聯繫人操作
我已經查看了文檔,並且我已經知道了SQL。但是在這一點上文檔有點雜亂,我不知道如何獲得向聯繫人發送消息的最佳方式。這裏是我想要做一些代碼:
public static Account best(Context context, long contact)
{
final ContentResolver resolver = context.getContentResolver();
final Cursor rawContacts = resolver.query(RawContacts.CONTENT_URI,
new String[]{RawContacts._ID},
RawContacts.CONTACT_ID + "=? AND " + registeredProtocolsSelection(),
new String[]{String.valueOf(contact)}, null);
while(rawContacts.moveToNext())
{
final long rawContactId = rawContacts.getLong(0);
Uri rawContactUri = ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId);
Uri entityUri = Uri.withAppendedPath(rawContactUri, Entity.CONTENT_DIRECTORY);
Cursor rawContact = resolver.query(entityUri,
new String[]{RawContacts.SOURCE_ID, Entity.DATA_ID, Entity.MIMETYPE, Entity.DATA1},
null, null, null);
}
return null;
}
我可以選擇事關我的應用程序,但當時我不知道如何加入所有RawContacts,我不能得到一個明確的架構數據庫。我不知道如何從那裏訪問StatusUpdate。目標就像ORDER BY presence
。
有沒有簡單的方法來做到這一點?有沒有辦法通過類似ORM的操作來像普通對象一樣操縱聯繫人?或者我們是否有機制在Android上輕鬆創建和管理自己的IM協議?
我在我的研究ORMLite中發現,可以極大地幫助我。有誰知道Android的聯繫人的SQLite數據庫的架構? 或者更好的人有沒有人知道一個聯繫人類與正確的註釋來獲取數據? – grea09