Skip to content

Instantly share code, notes, and snippets.

@yingshaoxo
Created January 24, 2018 15:54
Show Gist options
  • Save yingshaoxo/426d1b2557f95faa90aededee6697240 to your computer and use it in GitHub Desktop.
Save yingshaoxo/426d1b2557f95faa90aededee6697240 to your computer and use it in GitHub Desktop.
How to set global variable in Kotlin
  1. put this on top:
object GlobalVariable {
    var mp = MediaPlayer()
}
  1. use it everywhere GlobalVariable.mp

  2. so you won't have to worry about open too many MediaPlayer at the same time

@alashstein
Copy link

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment