Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class LocalService : Service() {
- // Binder given to clients
- private val mBinder: IBinder = LocalBinder()
- // Random number generator
- private val mGenerator: Random = Random()
- /**
- * Class used for the client Binder. Because we know this service always
- * runs in the same process as its clients, we don't need to deal with IPC.
- */
- inner class LocalBinder : Binder() {
- // Return this instance of LocalService so clients can call public methods
- val service: LocalService
- get() =// Return this instance of LocalService so clients can call public methods
- this@LocalService
- }
- override fun onBind(intent: Intent?): IBinder {
- return mBinder
- }
- /** method for clients */
- val randomNumber: Int
- get() = mGenerator.nextInt(100)
- }
Advertisement
Add Comment
Please, Sign In to add comment