您好,登录后才能下订单哦!
package com.virtual.robot.main;
import java.util.Timer;
import java.util.TimerTask;
import org.jivesoftware.smack.Chat;
import org.jivesoftware.smack.ChatManager;
import org.jivesoftware.smack.XMPPConnection;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.Window;
import android.view.WindowManager;
import com.virtual.robot.R;
import com.virtual.robot.common.ExitApplication;
/**
* start project
* @author zhuolin
*
*/
public class StartActivity extends ActionBarActivity {
public static XMPPConnection con;
public static Chat newChat;
public static ChatManager chatmanager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.startproject);
ExitApplication.getInstance().addActivity(this);
TimerTask task = new TimerTask() {
@Override
public void run() {
Intent intent = new Intent(StartActivity.this, ChooseLoginActivity.class);
startActivity(intent);
// TipMessage.logDebug("11111111111111111111111111111111");
// try {
// // Create a connection to server
// ConnectionConfiguration config = new ConnectionConfiguration(
// "192.168.1.107", 5222);
// config.setSASLAuthenticationEnabled(false);
// config.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled);
// con = new XMPPConnection(config);
//
// // connect and login with the username and pwd on server
// con.connect();
// con.login("zhuolin", "111111");
// TipMessage.logDebug("2222222222Authenticated = " + con.isAuthenticated());
//
// // add a listener to receive all messages
// addListener();
//
// chatmanager = con.getChatManager();
// newChat = chatmanager.createChat("zhuolin2@tclim/Spark 2.6.3",
// new MessageListener() {
// public void processMessage(Chat chat, Message message) {
// TipMessage.logDebug("I'm sending: "
// + message.getBody());
// }
// });
// newChat.sendMessage("hi");
// } catch (XMPPException e) {
// e.printStackTrace();
// } finally {
// //让线程休眠 然后再关闭连接
// try {
// Thread.sleep(30000);
// } catch (InterruptedException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// con.disconnect();
// }
}
};
Timer timer = new Timer();
timer.schedule(task, 1200);
}
// public static void addListener() {
// // just need Messages
// PacketFilter filterMessage = new PacketTypeFilter(Message.class);
//
// PacketListener myListener = new PacketListener() {
// public void processPacket(Packet packet) {
// TipMessage.logDebug("From: " + packet.getFrom() + "\n");
// System.out.println("Body: " + ((Message) packet).getBody());
// // when receiving prc's Message, just say something else again
// // and again, robot
// try {
// newChat.sendMessage("hi again");
// } catch (XMPPException e) {
// e.printStackTrace();
// }
// }
// };
// // register the listener to the connection
// con.addPacketListener(myListener, filterMessage);
// }
}
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。