您好,登錄后才能下訂單哦!
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 {
// //讓線程休眠 然后再關(guān)閉連接
// 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);
// }
}
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。