我試圖使用XMPP的消息事件接口。據我瞭解,您可以標記您發送的郵件並附上「送達通知請求」標誌,收件人不負責向您發送此通知。有沒有人成功實施這個?有人可以給我一些示例代碼嗎?我的代碼不起作用。我的聽衆(MessageEventNotificationListener,MessageEventRequestListener)回調從來不被稱爲:Android Smack MessageEventListener
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.chat);
PacketFilter filter = new MessageTypeFilter(Message.Type.chat);
VajasKifli.connection.addPacketListener(this, filter);
tv = (TextView) findViewById(R.id.textView1);
tvState = (TextView) findViewById(R.id.textView2);
et = (EditText) findViewById(R.id.editText1);
et.addTextChangedListener(this);
mem = new MessageEventManager(VajasKifli.connection);
mem.addMessageEventNotificationListener(this);
mem.addMessageEventRequestListener(this);
sdm = new ServiceDiscoveryManager(VajasKifli.connection);
VajasKifli.log("sdm: " + sdm);
stateManager = ChatStateManager.getInstance(VajasKifli.connection);
recipient = getIntent().getStringExtra("recipient");
chat = VajasKifli.connection.getChatManager().createChat(recipient, "chat-" + recipient, this);
VajasKifli.log("chat created: " + chat);
VajasKifli.connection.getChatManager().addChatListener(this);
sv = (ScrollView) findViewById(R.id.scrollView1);
handler = new ChatHandler();
}
public void onClickSend(View view)
{
String text = et.getText().toString();
if(text.length() > 0)
{
VajasKifli.log("sending text [" + text + "] to [" + recipient + "]");
try
{
Message message = new Message();
message.setBody(text);
MessageEventManager.addNotificationsRequests(message, false, true, false, false);
chat.sendMessage(message);
stateManager.setCurrentState(ChatState.active, chat);
lastState = ChatState.active;
tv.append("\n" + VajasKifli.connection.getUser().replaceFirst("@.*", "") + ": " + text);
sv.fullScroll(ScrollView.FOCUS_DOWN);
}
catch(XMPPException e)
{
VajasKifli.logError(e.toString());
}
//showToast("sent: " + text);
}
}
你可以請分享你如何解決這個問題? – Hunt