Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IllegalArgumentException when I exit #18

Open
vankad24 opened this issue Jan 31, 2021 · 3 comments
Open

IllegalArgumentException when I exit #18

vankad24 opened this issue Jan 31, 2021 · 3 comments

Comments

@vankad24
Copy link

I ran your example and when I exit the app this error appears:

    java.lang.RuntimeException: Unable to start service com.adroitandroid.near.discovery.client.UdpBroadcastService@73c0f23 with null: java.lang.NullPointerException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkNotNullParameter, parameter intent
        at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3449)
        at android.app.ActivityThread.-wrap21(ActivityThread.java)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1633)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:154)
        at android.app.ActivityThread.main(ActivityThread.java:6316)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:872)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:762)
     Caused by: java.lang.NullPointerException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkNotNullParameter, parameter intent
        at com.adroitandroid.near.discovery.client.UdpBroadcastService.onStartCommand(UdpBroadcastService.kt)
        at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3432)
        at android.app.ActivityThread.-wrap21(ActivityThread.java) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1633) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:154) 
        at android.app.ActivityThread.main(ActivityThread.java:6316) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:872) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:762) 

This happens on android 7, on android 10 everything is ok. I need some help. Thanks

@vankad24
Copy link
Author

vankad24 commented Feb 4, 2021

Thank you, @Mikhail57. You helped me solve this problem.

In the file near/discovery/client/UdpBroadcastService.kt
you need to add to the method stopSelf()

    ...
    override fun onTaskRemoved(rootIntent: Intent?) {
        stopSelf()
        super.onTaskRemoved(rootIntent)
    }
    ...

@Mikhail57
Copy link

As Android goes forward, Background Services becomes irrelevant, so you should move to Foreground Services ASAP. Or, as @vankad24 said, you may stop background service when the attached task removed or set the service's flag to stop when the task removed.

@DatL4g
Copy link
Contributor

DatL4g commented Mar 2, 2022

As this project is (nearly) dead and hard to maintain because it relies on old android code, I created a new one
Klient2Klient test this please instead

I will create an official release tomorrow, in the main time you can get the latest built commit from jitpack

implementaton("com.github.DatL4g.Klient2Klient:Klient2Klient:531f6f3dae")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants