本文整理汇总了Java中org.jivesoftware.smack.SmackAndroid.init方法的典型用法代码示例。如果您正苦于以下问题:Java SmackAndroid.init方法的具体用法?Java SmackAndroid.init怎么用?Java SmackAndroid.init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jivesoftware.smack.SmackAndroid
的用法示例。
在下文中一共展示了SmackAndroid.init方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
示例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);
}
示例3: 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();
}
示例4: 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();
}
示例5: 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);
}
}
示例6: 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);
}