# Regvision_Alljoyn_Android_Contacts **Repository Path**: regvision/Regvision_Alljoyn_Android_Contacts ## Basic Information - **Project Name**: Regvision_Alljoyn_Android_Contacts - **Description**: 利用Alljoyn android sdk实现手机联系人信息分享 1.本地获取联系人列表 2.将指定联系人分享给指定手机 3.将分享过来的联系人信息更新到本地 - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2014-09-14 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README #Regvision_Alljoyn_Android_Contacts 1.开启channel requestName(); bindSession(); advertise(); 2.关闭channel cancelAdvertise(); unbindSession(); releaseName(); 3.刷新channel列表 ChatBusListener中的foundAdvertisedName 4.加入session useSetChannelName(name); useJoinChannel(); 5.离开session application.useLeaveChannel(); 6.通信 发消息 private void doSendMessages() { Log.i(TAG, "doSendMessages()"); String message; while ((message = mChatApplication.getOutboundItem()) != null) { Log.i(TAG, "doSendMessages(): sending message \"" + message + "\""); /* * If we are joined to a remote session, we send the message over * the mChatInterface. If we are implicityly joined to a session * we are hosting, we send the message over the mHostChatInterface. * The mHostChatInterface may or may not exist since it is created * when the sessionJoined() callback is fired in the * SessionPortListener, so we have to check for it. */ try { if (mJoinedToSelf) { if (mHostChatInterface != null) { mHostChatInterface.Chat(message); } } else { mChatInterface.Chat(message); } } catch (BusException ex) { mChatApplication.alljoynError(ChatApplication.Module.USE, "Bus exception while sending message: (" + ex + ")"); } } } 收消息 @BusSignalHandler(iface = "org.alljoyn.bus.samples.chat", signal = "Chat") public void Chat(String string) { /* * See the long comment in doJoinSession() for more explanation of * why this is needed. * * The only time we allow a signal from the hosted session ID to pass * through is if we are in mJoinedToSelf state. If the source of the * signal is us, we also filter out the signal since we are going to * locally echo the signal. */ String uniqueName = mBus.getUniqueName(); MessageContext ctx = mBus.getMessageContext(); Log.i(TAG, "Chat(): use sessionId is " + mUseSessionId); Log.i(TAG, "Chat(): message sessionId is " + ctx.sessionId); /* * Always drop our own signals which may be echoed back from the system. */ if (ctx.sender.equals(uniqueName)) { Log.i(TAG, "Chat(): dropped our own signal received on session " + ctx.sessionId); return; } /* * Drop signals on the hosted session unless we are joined-to-self. */ // if (mJoinedToSelf == false && ctx.sessionId == mHostSessionId) { // Log.i(TAG, "Chat(): dropped signal received on hosted session " + ctx.sessionId + " when not joined-to-self"); // return; // } /* * To keep the application simple, we didn't force users to choose a * nickname. We want to identify the message source somehow, so we * just use the unique name of the sender's bus attachment. */ String nickname = ctx.sender; nickname = nickname.substring(nickname.length()-10, nickname.length()); Log.i(TAG, "Chat(): signal " + string + " received from nickname " + nickname); mChatApplication.newRemoteUserMessage(nickname, string); }