Android Question Killing previous instance (main).

janderkan

Well-Known Member
Licensed User
Longtime User
I have read the other posts about this issue, but I still have a question.
When I read a NFC tag everything works fine when the main activity is paused.
When app is running I get the message (Killing previous instance (main).)
It is not a problem that the activity is created again, but my MQTT connection is terminated too.
The MQTT connection is running in a separated service with StartForeground.
Reading the NFC should result in sending an MQTT message but Killing previous instance terminates connection to MQTT server.
I could put all MQTT messages in a queue and send them once I am connected again, but I hope someone have a better solution.
 
The MQTT connection shouldn't be affected by the activity being destroyed. Are you sure that there is no code in the activity that closes the connection?

I found the error.
This is the log:

** Activity (main) Pause, UserClosed = true **
Killing previous instance (main).
** Activity (main) Create, isFirst = false **
** Activity (main) Resume **

I did not expect UserClosed to be true when system Kills the instance.
Thank you for opening my eyes:)
 
Upvote 0
Back
Top