Java API getStates() Problem

4 years 11 months ago - 4 years 11 months ago #784 by mateuszowo
Hello,
I'm currently working on my project for univercity and I decided to use OpenSky API, which I'm very thankful for :)

But I have a problem in refreshing flight state.

My code works like in the example in documentation:
1. I create an OpenSkyApi object in main class:
OpenSkyApi api = new OpenSkyApi("NICKNAME", "PASSWORD");

...and I run getStates() method with given bounding box, so it works fine and i retrieve some current flights.

Then, I create a separate Thread for every flight, and in later time, every Thread has to refresh its states of flight (this is my project for concurrent programming, so I have to show the teacher that i can use Threads, but this is not the problem here)

2. I send "api" object to my second class called "Flight" (which is a new Thread) to the controller method and I'm trying to retrieve states there:
OpenSkyStates states = api.getStates(0, myicao24 );

where "myicao24" is String object with an icao24 inside, like: "06a086"

but when I compile that code, compiler says that there should be a String Array, so i make it like:
OpenSkyStates states = api.getStates(0, new String[] {myicao24} );
...as it would be an Array with one String inside, so compiler says that it's OK, but the getStates() method returns nullPointerException, even if I check this flight by executing getStates() method with "null" parameter for icao24 and given bounding box and this icao24 is visible as a result :/

What am I doing wrong? How to get states for only one exact icao24 in Java?
Please help me :)

Please Log in or Create an account to join the conversation.

Powered by Kunena Forum
This website uses cookies to offer you the best experience of our services. By using this website you agree to our privacy policy!