我使用linphone库最新版本。我想显示sip联系人状态。这是我的代码。
LinphoneFriend[] friends = LinphoneManager.getLc().getFriendList();
if (!ContactsManager.getInstance().isContactPresenceDisabled() && friends != null && contact.hasAddress()) {
friendStatus.setVisibility(View.VISIBLE);
String friendSipAddress = "";
for (LinphoneNumberOrAddress noa : contact.getNumbersOrAddresses()) {
if (noa.isSIPAddress()) {
friendSipAddress = noa.getValue();
}
}
LinphoneFriend friend = null;
for (int i = 0; i < friends.length; i++) {
Log.e("Friend","Addr " + friends[i].getAddress().asStringUriOnly());
Log.e("Friend","Name " + friends[i].getAddress().getDisplayName());
if (friends[i].getAddress().asStringUriOnly().equalsIgnoreCase(friendSipAddress)) {
friend = friends[i];
break;
}
}
if(friend!=null) {
PresenceModel presenceModel = friend.getPresenceModel();
if (presenceModel != null) {
//PresenceActivityType presenceActivity = friends[0].getPresenceModel().getActivity().getType();
PresenceActivityType presenceActivity = presenceModel.getActivity().getType();
android.util.Log.e("Linphone",friend.getName()+" " + presenceActivity);
if (presenceActivity == PresenceActivityType.Online) {
friendStatus.setImageResource(R.drawable.led_connected);
} else if (presenceActivity == PresenceActivityType.Busy) {
friendStatus.setImageResource(R.drawable.led_error);
} else if (presenceActivity == PresenceActivityType.Away) {
friendStatus.setImageResource(R.drawable.led_inprogress);
} else if (presenceActivity == PresenceActivityType.OnThePhone) {
friendStatus.setImageResource(R.drawable.on_phone);
} else if (presenceActivity == PresenceActivityType.Offline) {
friendStatus.setImageResource(R.drawable.led_disconnected);
} else {
friendStatus.setImageResource(R.drawable.led_disconnected);
}
} else {
friendStatus.setImageResource(R.drawable.led_error);
//Log.e("Linphone", "led_error");
}
} else {
//Log.e("Friend","friend null");
}
} else {
Log.e("Friend","friend visibility gone");
friendStatus.setVisibility(View.INVISIBLE);
}
但是LinphoneFriend对象总是给出PresenceModel。如何从linphonefriend获取状态模型?