my codes:
override fun onStartCommand(intent: Intent, flags: Int, startId: Int): Int
{
if (!this.isRunning)
{
this.isRunning = true
this.backgroundThread?.start()
}
return START_NOT_STICKY
}
errors:
Parameter specified as non-null is null: method co.okex.app.global.services.backgroundservices.SocketService.onStartCommand, parameter intent
android.app.ActivityThread.handleServiceArgs (ActivityThread.java:3943)
android.app.ActivityThread.access$2300 (ActivityThread.java:218)
android.app.ActivityThread$H.handleMessage (ActivityThread.java:1832)
android.os.Handler.dispatchMessage (Handler.java:102)
android.os.Looper.loop (Looper.java:145)
android.app.ActivityThread.main (ActivityThread.java:6934)
java.lang.reflect.Method.invoke (Method.java)
java.lang.reflect.Method.invoke (Method.java:372)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1404)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1199)
override fun onStartCommand(intent: Intent, flags: Int, startId: Int): Int
should be
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int
intent
may be null, so you must allow to receive null
and check for null
before using it.
Please refer to this onStartCommand