0
AndroidでXMPPConnectionを使用してGtalkのステータスを変更しようとしています。しかし、私がWi-Fiを試しているとき、接続できません。アプリケーションが応答していないことを示すポップアップを表示しています。私のコードはここにあります:AndroidでXMPPConnectionを使用してGtalkのステータスを変更しようとすると、アプリケーションが応答しない
ConnectionConfiguration conn = new ConnectionConfiguration("talk.google.com",Integer.parseInt("5222"),"gmail.com");
m_xmppConnection = new XMPPConnection(conn);
conn.setSASLAuthenticationEnabled(false);
conn.setDebuggerEnabled(true);
SASLAuthentication.supportSASLMechanism("PLAIN", 0);
try
{
m_xmppConnection.connect();
}
catch (XMPPException e1)
{
displayAlertDialog(e1.getMessage());
}
try
{
Log.d("Testing", "try to connect using XMPPConnection");
Log.d("Testing", "try to connect using XMPPConnection-----");
if(m_xmppConnection.isConnected())
{
Log.d("Testing", "It is connected with XMPPConnection");
m_xmppConnection.login(strUname, strPwd);
}
Log.d("Testing", "after giving user name and pwd-----");
Presence presence = new Presence(Presence.Type.available);
m_strGtPrevMsg = presence.getStatus();
m_spEditor.putString("prevmsg", m_strGtPrevMsg);
m_spEditor.commit();
presence.setStatus(strStatus);
Log.d("Testing", "status saved");
presence.setPriority(24);
presence.setMode(Presence.Mode.available);
m_xmppConnection.sendPacket(presence);
Log.d("Testing", "packet send");
}
catch(XMPPException e)
{
// e.printStackTrace();
displayAlertDialog(e.getMessage());
}
誰でも助けてください。
DDMSに表示されている例外:android.view.WindowManager $ BadTokenException:ウィンドウを追加できません - トークンnullはアプリケーション用ではありません –
私の答えや私の推測とは関係がありません。投稿したコードをどのコンテキストで実行するのかを明確にすることはできますか? – WarrenFaith
実際には、特定の時間に達すると(午後10時と同様に)私のアプリが起動します。これは私がサービスを利用してやっていることです。サービスが開始されると、Gtalkの状態を変更しようとします。 –