private void startRegistration ( ) { // Create a string map containing information about your service. Map < String , String > mRecordMap = new HashMap <> ( ) ; mRecordMap . put ( Configuration . PORT , Integer . toString ( mPort ) ) ; mRecordMap . put ( Configuration . IDENTIFIER , myIdentifier ) ; // Service information. Pass it an instance name, service type // Configuration.SERVICE_REG_TYPE , and the map containing // information other devices will want once they connect to this one. WifiP2pDnsSdServiceInfo mInfo = WifiP2pDnsSdServiceInfo . newInstance ( Configuration . SERVICE_INSTANCE + myIdentifier , Configuration . SERVICE_REG_TYPE , mRecordMap ) ; // Add the local service, sending the service info, network channel, // and listener that will be used to indicate success or failure of // the request. mManager . addLocalService ( mChannel , mInfo , new CustomizableActionListener ( this . mContext , TAG , "Added Local Service" , null , "Failed to add a service" , "Failed to add a service" , true ) ) ; //important: sets true to get detailed message when this method fails }
Registers a local service .