有添加好友没反应的吗??进来交流下!
添加好友监听没反应啊?
/**
* add frd
* @param view
*/
public void findFrd(View view){
if(!TextUtils.isEmpty(et_find.getText().toString().trim())){
try {
EMContactManager.getInstance().addContact(et_find.getText().toString().trim(), "add a friends?");
Toast.makeText(this, "add frd", Toast.LENGTH_SHORT).show();
} catch (EaseMobException e) {
e.printStackTrace();
Toast.makeText(this, "add frd fail", Toast.LENGTH_SHORT).show();
Log.d("mianAct", "add frd fail");
}
}
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
et_find = (EditText) findViewById(R.id.et_find);
EMContactManager.getInstance().setContactListener(new MyContactLis());
EMChatManager.getInstance().addConnectionListener(new MyConnecLis());
EMGroupManager.getInstance().addGroupChangeListener(new MyGroupChangeLis());
EMChat.getInstance().setAppInited();//init finish
Toast.makeText(this, "init lis finish", Toast.LENGTH_SHORT).show();
}
private class MyContactLis implements EMContactListener {
@Override
public void onContactAdded(List arg0) {
}
@Override
public void onContactAgreed(String username) {
}
@Override
public void onContactDeleted(List arg0) {
}
@Override
public void onContactInvited(String username, String reason) {
Log.i("contactlis", "get a contact invite from"+username);
Toast.makeText(getApplicationContext(), "get a contact invite from" + username, Toast.LENGTH_SHORT).show();
}
@Override
public void onContactRefused(String username) {
}
}
/**
* add frd
* @param view
*/
public void findFrd(View view){
if(!TextUtils.isEmpty(et_find.getText().toString().trim())){
try {
EMContactManager.getInstance().addContact(et_find.getText().toString().trim(), "add a friends?");
Toast.makeText(this, "add frd", Toast.LENGTH_SHORT).show();
} catch (EaseMobException e) {
e.printStackTrace();
Toast.makeText(this, "add frd fail", Toast.LENGTH_SHORT).show();
Log.d("mianAct", "add frd fail");
}
}
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
et_find = (EditText) findViewById(R.id.et_find);
EMContactManager.getInstance().setContactListener(new MyContactLis());
EMChatManager.getInstance().addConnectionListener(new MyConnecLis());
EMGroupManager.getInstance().addGroupChangeListener(new MyGroupChangeLis());
EMChat.getInstance().setAppInited();//init finish
Toast.makeText(this, "init lis finish", Toast.LENGTH_SHORT).show();
}
private class MyContactLis implements EMContactListener {
@Override
public void onContactAdded(List
}
@Override
public void onContactAgreed(String username) {
}
@Override
public void onContactDeleted(List
}
@Override
public void onContactInvited(String username, String reason) {
Log.i("contactlis", "get a contact invite from"+username);
Toast.makeText(getApplicationContext(), "get a contact invite from" + username, Toast.LENGTH_SHORT).show();
}
@Override
public void onContactRefused(String username) {
}
}
没有找到相关结果
已邀请:
8 个回复
lizg - ……
expawtest
lizg - ……
expawtest
expawtest
http://www.easemob.com/docs/android/buddy/#section-1 你看看
你帮我看下我上面贴的代码,哪里有问题吗??还是缺了什么东西,初始化我已经在application中初始化了
zhangnan
你帮我看下我上面贴的代码,哪里有问题吗??还是缺了什么东西,初始化我已经在application中初始化了 ...
这看起来没什么问题,我让你用demo试下,有没有试试
expawtest
这看起来没什么问题,我让你用demo试下,有没有试试
你们都的Demo到是没问题,但是我写的Demo来测试就是不行啊
lizg - ……