pwittchen / neurosky-android-sdk

Android SDK for the NeuroSky MindWave Mobile Brainwave Sensing Headset
https://pwittchen.github.io/neurosky-android-sdk/docs
Apache License 2.0
50 stars 16 forks source link

Issue with .isConnected() method #100

Open farzamani opened 4 years ago

farzamani commented 4 years ago

I already copied the code below to Gradle

dependencies { implementation 'com.github.pwittchen:neurosky-android-sdk:0.0.2' }

and imported com.github.pwittchen.neurosky.library.NeuroSky; in my project

then I tried to use neuroSky.isConnected() method but I got "Cannot resolve method 'isConnected()' in 'NeuroSky'" message

How could I fix it? Thanks

farzamani commented 4 years ago

image

Regards, Farhad

pwittchen commented 4 years ago

It's strange. Try to rebuild your project.

farzamani commented 4 years ago

I think I found the problem. In my project, the isConnected() method is not contained in NeuroSky.java file but in Preconditions.java (both files are downloaded via Gradle).

image

Perhaps I put wrong code in dependencies?

farzamani commented 4 years ago

Or maybe I can skip that isConnected() part since it already exist in startMonitoring() and stopMonitoring() method?

public void startMonitoring() { if (Preconditions.isConnected(device)) { device.start(); }}

public void stopMonitoring() { if (Preconditions.isConnected(device)) { device.stop(); }}

pwittchen commented 4 years ago

Method isConnected() is available as a public method in NeuroSky object and it's invoked from the Preconditions object. Invoking it from NeuroSky and Preconditions should have the same effect. It's strange that it's not working on your computer. It seems like a local bug or issue with your environment. Alternatively you can use Preconditions class if it works for you.

farzamani commented 4 years ago

There is no isConnected() method in NeuroSky.java. There is also no Preconditions object in that java file. Is it really like this? Because the library I've downloaded via Gradle is different from here

ps: actually there are no start() and stop() method too in the library maybe I need to re-check my env and project

image

Thank you for your response!