AndroidManifest.xml
· 121 B · XML
Raw
<service android:name=".HelloService" />
Intent(this, HelloService::class.java).also { intent ->
startService(intent)
}
| 1 | <service android:name=".HelloService" /> |
| 2 | |
| 3 | Intent(this, HelloService::class.java).also { intent -> |
| 4 | startService(intent) |
| 5 | } |
HelloService.kt
· 259 B · Kotlin
Raw
class HelloService : Service() {
override fun onBind(p0: Intent?): IBinder? {
return null
}
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
return super.onStartCommand(intent, flags, startId)
}
}
| 1 | class HelloService : Service() { |
| 2 | override fun onBind(p0: Intent?): IBinder? { |
| 3 | return null |
| 4 | } |
| 5 | |
| 6 | override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int { |
| 7 | return super.onStartCommand(intent, flags, startId) |
| 8 | } |
| 9 | |
| 10 | } |