本文整理匯總了Java中org.jivesoftware.smack.packet.Presence.getStatus方法的典型用法代碼示例。如果您正苦於以下問題:Java Presence.getStatus方法的具體用法?Java Presence.getStatus怎麽用?Java Presence.getStatus使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.jivesoftware.smack.packet.Presence
的用法示例。
在下文中一共展示了Presence.getStatus方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: presenceReceived
import org.jivesoftware.smack.packet.Presence; //導入方法依賴的package包/類
private void presenceReceived(Presence presence){
if (Presence.Type.available.equals(presence.getType()) &&
presence.getStatus() != null){
String from = presence.getFrom();
int index = from.indexOf('@');
if (index >= 0){
from = from.substring(0, index);
}
String status = presence.getStatus();
Intent intent = new Intent(Constants.PRESENCE_CHANGED);
intent.putExtra(Constants.BUDDY_ID, from);
intent.putExtra(Constants.PRESENCE_STATUS, status);
LocalBroadcastManager.getInstance(getApplicationContext())
.sendBroadcast(intent);
messageHistory.setOnline(from, status);
}
}
示例2: updateRosterListFrom
import org.jivesoftware.smack.packet.Presence; //導入方法依賴的package包/類
public void updateRosterListFrom(final Presence p) {
synchronized (rosterList) {
try {
final String s = p.getStatus();
final String t = p.getType().name();
final String n = chatEbl.getFullUserName(extractUsername(p.getFrom()));
if ("chatEcho".equals(s)) {
if (!rosterList.contains(n)) {
rosterList.add(n);
}
} else if ("chatOpen".equals(s)) {
if (!rosterList.contains(n)) {
rosterList.add(n);
}
if (chatWindowOpen) {
muc.changeAvailabilityStatus("chatEcho", Presence.Mode.available);
}
} else if ("chatClosed".equals(s)) {
if (chatWindowOpen) {
muc.changeAvailabilityStatus("chatEcho", Presence.Mode.available);
}
rosterList.remove(n);
} else if (t.equals("available")) {
if (!rosterList.contains(n)) {
rosterList.add(n);
}
} else if (t.equals("unavailable")) {
rosterList.remove(n);
}
if (!chatWindowOpen) {
rosterList.remove(getAnonymousNickName());
}
DBFactory.getInstance(false).commitAndCloseSession();
} catch (final Exception e) {
DBFactory.getInstance(false).rollbackAndCloseSession();
}
}
}
示例3: updateUsersDatabase
import org.jivesoftware.smack.packet.Presence; //導入方法依賴的package包/類
@SuppressWarnings("WeakerAccess")
int updateUsersDatabase(Presence p) {
String jid = p.getFrom().asBareJid().toString();
ContentValues values = new ContentValues(4);
values.put(Users.REGISTERED, 1);
// status
String status = p.getStatus();
if (status != null)
values.put(Users.STATUS, status);
else
values.putNull(Users.STATUS);
// delay
long timestamp;
DelayInformation delay = p.getExtension(DelayInformation.ELEMENT, DelayInformation.NAMESPACE);
if (delay != null) {
// delay from presence (rare)
timestamp = delay.getStamp().getTime();
}
else {
// logged in/out now
timestamp = System.currentTimeMillis();
}
if (timestamp > 0)
values.put(Users.LAST_SEEN, timestamp);
// public key extension (for fingerprint)
PublicKeyPresence pkey = p.getExtension(PublicKeyPresence.ELEMENT_NAME, PublicKeyPresence.NAMESPACE);
if (pkey != null) {
String fingerprint = pkey.getFingerprint();
if (fingerprint != null) {
// insert new key with empty key data
Keyring.setKey(getContext(), jid, fingerprint, new Date());
}
}
return getContext().getContentResolver().update(Users.CONTENT_URI,
values, Users.JID + "=?", new String[] { jid });
}