Strange behaviour



I use a phonegap plugin to communicate a bluetooth le device with my app. The app sends a message to the bluetooth device every 5 seconds and the bluetooth device replies.

If i ‘close’ the app (go somewhere else on the phone - not on the app), the communication continues in the background. When i re-open the app, i need to connect again. However after connecting, random messages are sent to the bluetooth device that appear to belong to the previous running session . This causes random messages and the app loses complete track of the messages.

If i stop the messages then ‘close’ the app, then reopen it, after i re-connect, everything works perfect.

Is there a way to completely close or clear any previous sessions of the app when i restart it?



This doesn’t sound like an AppStudio issue. It is likely more to do with the BT library, PhoneGap and the version of the OS you are using.


I did another quick test using phonegap.

If I start a timer that plays a sound every 5 seconds then I ‘close’ the app, the sound continues in the background. If I then re-open the app, the app restarts as though it has never been opened but the sound from the previous time continues and clearing the timer does nothing. This is the same problem with the Bluetooth messages. There’s no way for me to stop them as they were sent from the previous app session.

Does that make sense? Is there a way to kill the previous app session?



You’ll need to work with the PhoneGap docs on this one.


There are some flags in the Android manifest that control how the app restarts. Maybe android:launchMode in activity?

Can these be incorporated in App Studio? If so, where?



You may need to go to PhoneGap CLI to do this.

closed #7

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.