Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Android Kotlin error when app come back from background

Aperta
#266 0 commenti 1 reazione 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
1-2 giorni
Idoneità per principianti
15/100
Tipo di issue
Bug
Chiarezza
Da chiarire
Stato di attività
Ferma
Stack tecnologico
android, java, kotlin
Ambito
mobile, networking

Direzione di ricerca

The crash is a Kotlin null-check (Intrinsics.checkParameterIsNotNull, parameter code) inside the reporter's own PusherRepositoryImp$connect$1.onError, called from WebSocketConnection$5.run in the library's WebSocketConnection.java:238. Start by reading how the library's connection error callback passes its arguments, then check whether the reporter's onError signature declares a nullable code. The issue has no comments and no reproduction, so 'done' is not defined here and it would need a maintainer decision before any change.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

question

version pusher = "2.2.1"
version pusherNotifications = "1.6.2"
Hi...I have a ugly error when app come back from background....
When I detected that the app is going to background I do this

 override fun closePrincipalChannelConnection() {
        Log.d(TAG,"closePrincipalChannelConnection")
        channel?.unbind("chat-message") {
            Log.d(TAG,"onEvent")
        }
        channel?.unbind("new-follower") {
            Log.d(TAG,"onEvent")
        }
       pusher?.unsubscribe(channelName)
    }

Then when 5-10 pass and the app come back from background, I mean, now the app is in foreground, then call

  override fun connectToGeneral(){
            channelName = "presence-$profileId"
            channel= pusher?.subscribePresence(channelName, object : PresenceChannelEventListener {
                override fun onAuthenticationFailure(message: String, e: Exception) {
                    Log.d(TAG,String.format("Authentication failure due to [%s], exception was [%s]", message, e))
                }

                override fun onSubscriptionSucceeded(channelName: String?) {
                    Log.d(TAG,"onSubscriptionSucceeded$channelName")

                }

                override fun onEvent(event: PusherEvent?) {
                    Log.d(TAG,"onEvent"+event?.data)
                }

                override fun onUsersInformationReceived(channelName: String?, users: MutableSet<User>?) {
                    Log.d(TAG, "onUsersInformationReceived$channelName${users.toString()}")
                }

                override fun userUnsubscribed(channelName: String?, user: User?) {
                    Log.d(TAG, "userUnsubscribed$channelName${user.toString()}")

                }

                override fun userSubscribed(channelName: String?, user: User?) {
                    Log.d(TAG, "userSubscribed$channelName${user.toString()}")
                }
            })

            channel?.bind("chat-message", object: PresenceChannelEventListener{
                override fun onAuthenticationFailure(message: String?, e: java.lang.Exception?) {
                    Log.d(TAG,String.format("Authentication failure due to [%s], exception was [%s]", message, e))

                }

                override fun onUsersInformationReceived(channelName: String?, users: MutableSet<User>?) {
                    Log.d(TAG, "onUsersInformationReceived$channelName${users.toString()}")
                }

                override fun userUnsubscribed(channelName: String?, user: User?) {
                    Log.d(TAG, "userUnsubscribed$channelName${user.toString()}")

                }

                override fun userSubscribed(channelName: String?, user: User?) {
                    Log.d(TAG, "userSubscribed$channelName${user.toString()}")
                }

                override fun onEvent(event: PusherEvent?) {
                    Log.d(TAG,"onEvent"+event?.data)

                    logicTypeMessage(PusherEvents.EVENT_TYPE_MESSAGE,event?.data ?:"")
                }

                override fun onSubscriptionSucceeded(channelName: String?) {
                    Log.d(TAG,"onSubscriptionSucceeded$channelName")
                }
            })

            channel?.bind("new-follower", object: PresenceChannelEventListener{
                override fun onAuthenticationFailure(message: String?, e: java.lang.Exception?) {
                    Log.d(TAG,String.format("Authentication failure due to [%s], exception was [%s]", message, e))

                }

                override fun onUsersInformationReceived(channelName: String?, users: MutableSet<User>?) {
                    Log.d(TAG, "onUsersInformationReceived$channelName${users.toString()}")
                }

                override fun userUnsubscribed(channelName: String?, user: User?) {
                    Log.d(TAG, "userUnsubscribed$channelName${user.toString()}")

                }

                override fun userSubscribed(channelName: String?, user: User?) {
                    Log.d(TAG, "userSubscribed$channelName${user.toString()}")
                }

                override fun onEvent(event: PusherEvent?) {
                    Log.d(TAG,"onEvent"+event?.data)

                    logicTypeMessage(PusherEvents.EVENT_TYPE_CONNECTIONS,event?.data ?:"")

                }

                override fun onSubscriptionSucceeded(channelName: String?) {
                    Log.d(TAG,"onSubscriptionSucceeded$channelName")
                }
            })
       

    }

The app crash whit the following message

Fatal Exception: java.lang.IllegalArgumentException
Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull, parameter code
com.xxx.repository.pusher.PusherRepositoryImp$connect$1.onError (Origen desconocido:7)
com.pusher.client.connection.websocket.WebSocketConnection$5.run (WebSocketConnection.java:238)
com.pusher.client.util.Factory$1.run (Factory.java:119)
java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1162)
java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:636)
java.lang.Thread.run (Thread.java:764)

whats wrong in my code??
thanks

Lingua principale
Java
Stelle
315
Fork
140
Merge medio
11g 5h
PR unite (30g)
4

Preparare l'ambiente

  • Nessun Dockerfile né file Docker Compose
  • Ha un modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di pusher/pusher-websocket-java

Tutte le issue di pusher/pusher-websocket-java

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.