我试图通过https://github.com/igniterealtime/Smack与Smack 4.1.0 rc1进行XMPP连接
我遵循了这个指南:https://github.com/igniterealtime/Smack/wiki/Smack-4.1-Readme-and-Upgrade-Guide导入Gradle.
源代码:
package com.example.xmpp_app;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
import android.view.MenuItem;
import org.jivesoftware.smack.AbstractXMPPConnection;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.tcp.XMPPTCPConnection;
import org.jivesoftware.smack.tcp.XMPPTCPConnectionConfiguration;
import java.io.IOException;
public class MainActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Create the configuration for this new connection
XMPPTCPConnectionConfiguration.Builder configBuilder = XMPPTCPConnectionConfiguration.builder();
configBuilder.setUsernameAndPassword("test@example.com", "password123");
configBuilder.setResource("test");
configBuilder.setServiceName("example.com");
AbstractXMPPConnection connection = new XMPPTCPConnection(configBuilder.build());
// Connect to the server
try {
connection.connect();
} catch (SmackException e) …Run Code Online (Sandbox Code Playgroud) 我已经在我的笔记本电脑上安装了ubuntu并安装了python,安装python2.7.5之后我试图在终端上运行python脚本,但是它说模块没有找到,我开始下载所有模块但是仍然说模块没找到.升级到python2.7.9之后,它仍然说同样的,所以我安装了正确导入模块的python iddle shell.
为什么会这样?为什么它在python shell上工作但不在终端上工作.终端只识别模块,如sys,os ..和一些内置模块,但没有安装.我很感激你的帮助.(我刚开始使用linux)

我创建了一个自定义通知,但是当我使用主页按钮暂停活动并且收到通知时,我按下通知,它会创建一个新活动,并且不会恢复预览活动,当我按下后退按钮时,它会转到预览一个是同一个窗口。我已经尝试过singleTop, singleTask, singleIntent,它可以工作,但当消息输入时它不会更新活动,就像预览活动处于暂停状态一样。我该如何修复它?
如果我没有解决方案来恢复活动或销毁暂停的活动或重新启动活动,有没有办法做到这一点?
\n\npublic void CustomNotification(String strtext) {\n // Using RemoteViews to bind custom layouts into Notification\n RemoteViews remoteViews = new RemoteViews(getPackageName(),\n R.layout.customnotification);\n\n // Set Notification Title\n String strtitle = getString(R.string.customnotificationtitle);\n // Open NotificationView Class on Notification Click\n Intent intent = new Intent(this, NotificationView.class);\n // Send data to NotificationView Class\n intent.putExtra("title", strtitle);\n intent.putExtra("text", strtext);\n intent.putExtra("String T", "");\n //intent.putExtra("Integer C", 0);\n\n // Open NotificationView.java Activity\n PendingIntent pIntent = PendingIntent.getActivity(this, 0, intent,\n PendingIntent.FLAG_UPDATE_CURRENT);\n\n NotificationCompat.Builder builder = new …Run Code Online (Sandbox Code Playgroud) 嘿我正在尝试在另一个人开始写入时获得输入状态,即使它返回一条状态为消息的空消息,但它来自proccessMessage方法.不应该在州改变吗?我没有启用任何PacketProvider,我是否必须这样做,所以这将在stateChanged方法中返回?我将不胜感激任何帮助.
newChat = chatmanager.createChat(contactUsername + sc.DOMAIN, new ChatStateListener() {
@Override
public void stateChanged(Chat chat, ChatState state) {
if (ChatState.composing.equals(state)) {
Log.d("Chat State",chat.getParticipant() + " is typing..");
} else if (ChatState.gone.equals(state)) {
Log.d("Chat State",chat.getParticipant() + " has left the conversation.");
} else {
Log.d("Chat State",chat.getParticipant() + ": " + state.name());
}
}
@Override
public void processMessage(Chat chat, Message message) {
System.out.println("Received message: " + message);
}
});
Run Code Online (Sandbox Code Playgroud)
日志:
06-15 14:28:47.679 9949-9983/com.example.example I/System.out? Received message: <message to='+931111111111@example.com' from='+930000000000@example.com/Spark 2.6.3' id='AUJG0-42' type='chat'><thread>097uC9</thread><inactive xmlns='http://jabber.org/protocol/chatstates'/></message>
Run Code Online (Sandbox Code Playgroud)