neurosky-android-sdk icon indicating copy to clipboard operation
neurosky-android-sdk copied to clipboard

Issue with .isConnected() method

Open farzamani opened this issue 3 years ago • 6 comments

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 avatar Oct 27 '20 09:10 farzamani

image

Regards, Farhad

farzamani avatar Oct 27 '20 09:10 farzamani

It's strange. Try to rebuild your project.

pwittchen avatar Oct 27 '20 09:10 pwittchen

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 avatar Oct 27 '20 10:10 farzamani

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(); }}

farzamani avatar Oct 27 '20 10:10 farzamani

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.

pwittchen avatar Oct 27 '20 11:10 pwittchen

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!

farzamani avatar Oct 27 '20 12:10 farzamani