WEB开发网
开发学院手机开发Android 开发 Android 操练:Gtalk(显示好友列表) 阅读

Android 操练:Gtalk(显示好友列表)

 2010-04-12 15:54:00 来源:WEB开发网   
核心提示:此处注意:在操作这个之前,要在先前<登录>程序里面修改两处:1. mGtalkSession = xmppservice.createGTalkSession(login_User.getText().toString(),login_Pwd.getText().toString());mGtalkSess

此处注意:

在操作这个之前,要在先前<登录>程序里面修改两处:

1. mGtalkSession = xmppservice.createGTalkSession(login_User.getText().toString(),login_Pwd.getText().toString());

mGtalkSession.requestRoster();

2. case 5:

mGtalkSession.setPresence(new Presence(Im.PresenceColumns.AVAILABLE, "Am here now!"));

createContact();

logMessage("the client requested roster from the server."); 复制内容到剪贴板

代码:

import android.app.Activity;

import android.database.Cursor;

import android.graphics.Typeface;

import android.os.Bundle;

import android.provider.Im;

import android.util.Log;

import android.view.View;

import android.view.View.OnClickListener;

import android.widget.ImageView;

import android.widget.TableLayout;

import android.widget.TableRow;

import android.widget.TextView;

public class ContactsActivity extends Activity {

private static final String TAG="microChat.ContactsView";

private static final boolean DEBUG=true;

@Override

protected void onCreate(Bundle icicle) {

super.onCreate(icicle);

setContentView(R.layout.contacts);

// Run a query against CONTENT_URI = "content://im/contacts"

Cursor cursor=managedQuery(Im.Contacts.CONTENT_URI, null,null, null, null);

TableLayout layout=(TableLayout)findViewById(R.id.contacts_table_layout);

int PRESENCE_STATUS=cursor.getColumnIndex(Im.PresenceColumns.PRESENCE_STATUS);

int NICKNAME=cursor.getColumnIndex(Im.ContactsColumns.NICKNAME);

int USERNAME=cursor.getColumnIndex(Im.ContactsColumns.USERNAME);

int numRows=cursor.count();

cursor.first();

for(int i=0;i< p>

{ int presence=(int)cursor.getLong(PRESENCE_STATUS);

1 2  下一页

Tags:Android 操练 Gtalk

编辑录入:coldstar [复制链接] [打 印]
赞助商链接