Skip to content

International Space Station Online Tracker implemented using Kotlin, Coroutines for handling public apis

Notifications You must be signed in to change notification settings

mteranova9/ISSTracker-Kotlin

Repository files navigation

ISS-Tracker

International Space Station Online Tracker implemented using Kotlin, Coroutines for handling public open apis from International Space Station Current Location official website http://open-notify.org/Open-Notify-API/ISS-Location-Now/ Here I used apis to get current whereabouts of space station http://api.open-notify.org/iss-now.json and currently how many peoples in space using another public available api http://api.open-notify.org/astros.json

I used google map, you can generate an api key for google map sdk for android if you need go to this link https://developers.google.com/maps/documentation/android-sdk/#

Screenshot2 screenshot1

Used coroutines to show the current location of the ISS and update it every 5 seconds using timer:

timer = Timer()
 timerTask = object : TimerTask() {
   
   override fun run() {
          
          handler.post(Runnable {
              
              CoroutineScope(Dispatchers.IO).launch {
                  
                  val request = apiService.getISSNow()
                   
                   try {
                     
                     val response = request.await()
                       
                       withContext(Dispatchers.Main) {
                        
                        if (response.message == "success") {
                    
                            initISSLocation(response.whereAbouts)
                     
                         }
                   
                     }
                  
                  } catch (e: HttpException) {
                        Log.d("REQUEST", "Exception ${e.message}")
                   
                   } catch (e: Throwable) {
                        Log.d("REQUEST", "Ooops: Something else went wrong")
                   
                  }

                }
            })
        }
    }
    timer.schedule(timerTask, 5000, 5000)

About

International Space Station Online Tracker implemented using Kotlin, Coroutines for handling public apis

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages