ble180 / Wroup

Android - WiFi Direct Library
38 stars 13 forks source link

Error creating group #2

Open yleyvag opened 7 years ago

yleyvag commented 7 years ago

I'm using your library but it doesn't work for me. The only function is called is onErrorServiceRegistered and I received BUSY. I don't know what I'm doing wrong. I tested on a Samsung Galaxy S5 SM-G900V (Android 6.0.1) and Samsung Galaxy Exhibit SGH-T599N (Android 4.1.2). Here's my class:

public class InviteActivity extends AppCompatActivity {

WiFiDirectBroadcastReceiver wiFiDirectBroadcastReceiver;
WroupService wroupService;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_invite);

    wiFiDirectBroadcastReceiver = WiFiP2PInstance.getInstance(this).getBroadcastReceiver();
    wroupService = WroupService.getInstance(getApplicationContext());

    registerService();
}

@Override
protected void onResume() {
    super.onResume();

    IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(WifiP2pManager.WIFI_P2P_STATE_CHANGED_ACTION);
    intentFilter.addAction(WifiP2pManager.WIFI_P2P_PEERS_CHANGED_ACTION);
    intentFilter.addAction(WifiP2pManager.WIFI_P2P_CONNECTION_CHANGED_ACTION);
    intentFilter.addAction(WifiP2pManager.WIFI_P2P_THIS_DEVICE_CHANGED_ACTION);
    registerReceiver(wiFiDirectBroadcastReceiver, intentFilter);
}

@Override
protected void onPause() {
    super.onPause();
    unregisterReceiver(wiFiDirectBroadcastReceiver);
}

private void registerService() {
    wroupService.registerService("Application", new ServiceRegisteredListener() {
        @Override
        public void onSuccessServiceRegistered() {
            Log.d("app", "onSuccessServiceRegistered");
        }

        @Override
        public void onErrorServiceRegistered(WiFiP2PError wiFiP2PError) {
            Log.d("app", "onErrorServiceRegistered " + wiFiP2PError.toString());
        }
    });

    wroupService.setClientConnectedListener(new ClientConnectedListener() {
        @Override
        public void onClientConnected(WroupDevice wroupDevice) {
            Log.d("app", "setClientConnectedListener");
        }
    });

    wroupService.setClientDisconnectedListener(new ClientDisconnectedListener() {
        @Override
        public void onClientDisconnected(WroupDevice wroupDevice) {
            Log.d("app", "setClientDisconnectedListener");
        }
    });
}
perlics commented 6 years ago

Your wifi is off.