ProjectSPAN / android-manet-manager

SPAN - Android Manet Manager
72 stars 37 forks source link

Adding manet manager to a new app #24

Open aleixsb opened 10 years ago

aleixsb commented 10 years ago

Hi! I've been trying to add the manet manager to an app that i'm building, but with no success.

I've created the JAR from the MM and imported to my app. I try to start de ad-hoc like this:

manet = new ManetHelper(this);
manet.registerObserver(this);
EulaHelper eula = new EulaHelper(this, this);
    eula.showDialog();
    manet.connectToService();

I'll started creating a simple app that only starts an ad-hoc network with a button but every time I recive an error:

03-04 11:01:03.930: E/ManetHelper::sendMessage(4021): You must connect to the ManetService before sending messages to it!

I understand I have some error with the service but don't know what i'm doing wrong.. Anyone can help me?

jrobble commented 10 years ago

My guess is that you have to wait for the onServiceConnected() callback to be invoked after calling manet.connectToService(). You can then do what you need to do next in the body of onServiceConnected(), or set a flag there that you read elsewhere. Refer to how this class does it: https://github.com/ProjectSPAN/android-manet-manager/blob/master/AndroidManetManager/src/org/span/manager/MainActivity.java