• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java SmackAndroid类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.jivesoftware.smack.SmackAndroid的典型用法代码示例。如果您正苦于以下问题:Java SmackAndroid类的具体用法?Java SmackAndroid怎么用?Java SmackAndroid使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SmackAndroid类属于org.jivesoftware.smack包,在下文中一共展示了SmackAndroid类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: onCreate

import org.jivesoftware.smack.SmackAndroid; //导入依赖的package包/类
@Override
public void onCreate() {
    SmackAndroid.init(getApplicationContext());
    configure();

    // create the global wake lock
    PowerManager pwr = (PowerManager) getSystemService(Context.POWER_SERVICE);
    mWakeLock = pwr.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, Kontalk.TAG);
    mWakeLock.setReferenceCounted(false);

    mLocalBroadcastManager = LocalBroadcastManager.getInstance(this);
    mPushService = PushServiceManager.getInstance(this);

    // create idle handler
    HandlerThread thread = new HandlerThread("IdleThread", Process.THREAD_PRIORITY_BACKGROUND);
    thread.start();

    mIdleHandler = new IdleConnectionHandler(this, thread.getLooper());
    mHandler = new Handler();
}
 
开发者ID:ShadiNachat,项目名称:Chatting-App-,代码行数:21,代码来源:MessageCenterService.java


示例2: ConnectionManager

import org.jivesoftware.smack.SmackAndroid; //导入依赖的package包/类
public ConnectionManager(Context context,
		ConnectionStatusCallback statusCallback,
		CommunicationManager communicationManager) {
	this.statusCallback = statusCallback;
	this.communicationManager = communicationManager;

	smack = SmackAndroid.init(context);

	SASLAuthentication.registerSASLMechanism(GTalkOAuthSASLMechanism.NAME,
			GTalkOAuthSASLMechanism.class);
	SASLAuthentication
			.supportSASLMechanism(GTalkOAuthSASLMechanism.NAME, 0);

	ConnectionConfiguration configuration = new ConnectionConfiguration(
			"talk.google.com", 5222, "gmail.com");
	configuration.setSASLAuthenticationEnabled(true);

	connection = new XMPPConnection(configuration);
}
 
开发者ID:nickglobal,项目名称:TvPoo,代码行数:20,代码来源:ConnectionManager.java


示例3: connectToServer

import org.jivesoftware.smack.SmackAndroid; //导入依赖的package包/类
private void connectToServer() {
    ExecutorService executor = Executors.newSingleThreadExecutor();
    if (isServerUrlNotNull())
    {
        executor.execute(new Runnable() {
            @Override
            public void run() {
                logs.info("Getting xmpp connection configuration");
                mSmackAndroid = SmackAndroid.init(XmppService.this);
                mConnection = getConfiguredConnection(HOST);

                try {
                    mUserLogin = Prefs.getApiUsername(XmppService.this);
                    mUserPassword = Prefs.getApiKey(XmppService.this);
                    mUserJid = mUserLogin + "@" + HOST;

                    logs.info("Connecting to xmpp server");
                    Log.i("XmppService", "login: " + mUserLogin + " password: " + mUserPassword +
                            " jid: " + mUserJid);

                    mConnection.connect();
                    mConnection.login(mUserLogin, mUserPassword);

                    setMessageListener(mConnection);
                    setPubsubListener(mConnection);
                } catch (Exception e) {
                    Log.i(TAG, "Error during connection", e);
                    e.printStackTrace();
                    //try again
                    mConnection.disconnect();
                    connectToServer();
                }
                }
        });
    }
}
 
开发者ID:42cc,项目名称:p2psafety,代码行数:37,代码来源:XmppService.java


示例4: NumberValidator

import org.jivesoftware.smack.SmackAndroid; //导入依赖的package包/类
public NumberValidator(Context context, EndpointServer server, String name, String phone, PersonalKey key, String passphrase) {
    mContext = context.getApplicationContext();
    mServer = server;
    mName = name;
    mPhone = phone;
    mKey = key;
    mPassphrase = passphrase;

    mConnector = new XMPPConnectionHelper(mContext, mServer, true);
    mConnector.setRetryEnabled(false);

    SmackAndroid.init(context.getApplicationContext());
    configure();
}
 
开发者ID:ShadiNachat,项目名称:Chatting-App-,代码行数:15,代码来源:NumberValidator.java


示例5: onCreate

import org.jivesoftware.smack.SmackAndroid; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_login);
    SmackAndroid.init(this);
    ButterKnife.inject(this);
    init();

}
 
开发者ID:gongmingqm10,项目名称:SmackDemo,代码行数:10,代码来源:LoginActivity.java


示例6: logInToClient

import org.jivesoftware.smack.SmackAndroid; //导入依赖的package包/类
private void logInToClient() {
    Log.i(TAG, "logInToClient");

    if (hubCommandsClient != null) {
        Log.e(TAG, "Client is alerady connected");
        return;
    }

    ImageButton connectBtn = (ImageButton) findViewById(R.id.connectButton);
    connectBtn.setEnabled(false);

    /* TODO - remove comment if for some reason you see that the hub is not responsive and might need to authenticate with the myharmony web service
    String loginToken = auth.getLoginToken(Configuration.myHarmonyUser, Configuration.myHarmonyPassword);
    if (loginToken == null) {
        return;
    }
    */
    String loginToken = "testtesttesttest";

    //this needs to be called before XMPP is used in the app
    SmackAndroid.init(this);

    //if on home wifi then use the home wifi IP and port, otherwise use the external ones
    String hubIP = Configuration.hubWifiAddress;
    int xmppPort = Configuration.hubWifiXmppPort;
    WifiManager wifiMgr = (WifiManager) getSystemService(Context.WIFI_SERVICE);
    WifiInfo mWifi = wifiMgr.getConnectionInfo();
    String wifiName = mWifi.getSSID();
    if (wifiName == null || !wifiName.equals(Configuration.homeWifiSSID)) {
        hubIP = Configuration.hubInternetAddress;
        xmppPort = Configuration.hubInternetXmppPort;
    }

    hubCommandsClient = new Client(hubIP, xmppPort, this, this);
    //if (!auth.getSessionToken(loginToken, "192.168.2.128", hubCommandsClient)) {
    if (!auth.getSessionToken(loginToken, hubIP, xmppPort, hubCommandsClient)) {
        connectBtn.setEnabled(true);
    }
}
 
开发者ID:itaybia,项目名称:androidHarmony,代码行数:40,代码来源:MainActivity.java


示例7: XMPPCommunicator

import org.jivesoftware.smack.SmackAndroid; //导入依赖的package包/类
/**
* XMPPClass Constructor
* @param username : XMPP server username
* @param password : XMPP server password
* @param topicName : XMPP main topic name (RC topic name)
* @param Server : XMPP Server name
* @param appContext : The application context
*/
public XMPPCommunicator(String username, String password, String topicName, String Server, Context appContext){
	
	NodeListeners = new HashMap<String, ItemEventCoordinator>();
	Nodes = new HashMap<String, Node>();
	
	Username = username;
	Password = password;
	Topic = topicName;
	ctx = appContext;
	flag = true;
	
	serverName = Server;
	
	msgPub = new MessagePublisher("XMPP");
	
	//Init aSmack
	SmackAndroid.init(ctx);
	
	//Set the reply timeout of asmack in ms to avoid server not responding fast enough if busy
	//SmackConfiguration.setPacketReplyTimeout(10000);

	// XMPP CONNECTION		
	connConfig = new ConnectionConfiguration(serverName,PORT);
	
	//connConfig.setSASLAuthenticationEnabled(true);
	connConfig.setCompressionEnabled(true);
	connConfig.setSecurityMode(SecurityMode.disabled);
	/*
	//Connection configuration - generates a warning on startup because the truststore path is set to null
	if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
		connConfig.setKeystoreType("AndroidCAStore");
		//connConfig.setKeystorePassword(null);
		connConfig.setKeystorePath(null);
		//connConfig.set
	} else {
		connConfig.setKeystoreType("BKS");
	    String path = System.getProperty("javax.net.ssl.trustStore");
	    if (path == null)
	        path = System.getProperty("java.home") + File.separatorChar + "etc"
	            + File.separatorChar + "security" + File.separatorChar
	            + "cacerts.bks";
	    connConfig.setKeystorePath(path);
	}
	*/
	xmpp = new XMPPTCPConnection(connConfig);
	
}
 
开发者ID:NitLab,项目名称:Android_Resource_Controller,代码行数:56,代码来源:XMPPCommunicator.java



注:本文中的org.jivesoftware.smack.SmackAndroid类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java TextFileInputMeta类代码示例发布时间:2022-05-22
下一篇:
Java GlobalGrouping类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap