gtalkservice?gtalk怎么加好友?gsf.gtalkservice?建立一个GTalk连接和启动一个IM会

电脑杂谈  发布时间:2016-10-10 04:01:10  来源:网络整理

你是否正在寻找关于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

    相关阅读
      发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

      热点图片
      拼命载入中...