你是否正在寻找关于gtalkservice的内容?让我把最实时的东西奉献给你:
建立一个GTalk连接和启动一个IM会话
在默认情况下,一个设备需要单一的GTalk连接来支持单一的IM会话,并且这个会话使用设备所有者的用户名。你可以使用GTalk服务的getDefaultConnection和默认连接的getDefaultSession方法分别得到默认连接和会话,如下面的片段所示:
IGTalkConnection gTalkConnection = gtalkservice.getDefaultConnection();
IImSession imSession = gTalkConnection.getDefaultImSession();
IM会话用于发送文本和数据消息,设定用户状态,管理IM联系人名单和管理组聊等,。
在Android应用程序中,IM会话是处理即时消息的最基本的接口。因此,接下来的代码片段显示了应用程序中ServiceConnection绑定GTalk服务的更加典型的实现。它确保了IM会话对象总是有效的。
private IGTalkConnection gTalkConnection = null;
private IImSession imSession = null;
private ServiceConnection gtalkserviceConnection = new ServiceConnection() {
// When the service connects, get the default GTalk session.
public void onServiceConnected(ComponentName className, IBinder service)
{
IGTalkService gtalkService = Igtalkservice.Stub.asInterface(service);
try {
gTalkConnection = gtalkservice.getDefaultConnection();
imSession = gTalkConnection.getDefaultImSession();
} catch (RemoteException e) { }
}
// When the service disconnects, clear the GTalk session.
public void onServiceDisconnected(ComponentName className) {
gTalkConnection = null;
imSession = null;
}
};
posted on
以上就是关于gtalkservice的全部内容,相信你一定会非常满意。
本文来自电脑杂谈,转载请注明本文网址:
https://www.pc-fly.com/a/ruanjian/article-18452-1.html
颜值高
弄僵后反而弊大于利
炒作而已
更新完游戏都进不了