I have attached a minimal program that seemed to work initially (but see below), but I'm not sure I've done it the "right" way, particularly now I've found a problem.
This minimal program has two buttons, IN and OUT. Pressing the IN button disables that button and enables the OUT button, and vice-versa. You can only be IN or OUT, and the program saves the in/out state so that it can be restored when the program runs again. That's all the main section does.
I want the user to be able to see whether they are IN or OUT even if the program is not in the foreground. So, I've added a sticky service and put notification code in there. Now, each time the user presses a button, the status is shown in the notification icon. And if the user pulls down the notifications, they can tap to get back to the main program.
The problem is that it only seems to work while my phone is plugged in (to the PC that I'm developing on).
If I unplug the phone, then pull down the notification area, then tap on the notification, the main screen opens but the IN and OUT buttons are not displayed. I have turned the phone off then on again, and run the app again (from its icon), but the IN and OUT buttons are still not displayed, whether the phone is connected to the PC or not.
The only way to get the app back to normal seems to be to plug the phone into the PC and download the app again via B4A, and then the buttons appear again.
Obviously, I've done something wrong. Does anyone have any ideas what it might be?
I have two other questions about the program, but I suspect I'd be asked to start a new thread if I put them here, so I'll leave them for later.
In case it matters, my phone is a Google Nexus 4 running Android 5.1.1 and B4A is V7.0.1
Thanks,
Peter
This minimal program has two buttons, IN and OUT. Pressing the IN button disables that button and enables the OUT button, and vice-versa. You can only be IN or OUT, and the program saves the in/out state so that it can be restored when the program runs again. That's all the main section does.
I want the user to be able to see whether they are IN or OUT even if the program is not in the foreground. So, I've added a sticky service and put notification code in there. Now, each time the user presses a button, the status is shown in the notification icon. And if the user pulls down the notifications, they can tap to get back to the main program.
The problem is that it only seems to work while my phone is plugged in (to the PC that I'm developing on).
If I unplug the phone, then pull down the notification area, then tap on the notification, the main screen opens but the IN and OUT buttons are not displayed. I have turned the phone off then on again, and run the app again (from its icon), but the IN and OUT buttons are still not displayed, whether the phone is connected to the PC or not.
The only way to get the app back to normal seems to be to plug the phone into the PC and download the app again via B4A, and then the buttons appear again.
Obviously, I've done something wrong. Does anyone have any ideas what it might be?
I have two other questions about the program, but I suspect I'd be asked to start a new thread if I put them here, so I'll leave them for later.
In case it matters, my phone is a Google Nexus 4 running Android 5.1.1 and B4A is V7.0.1
Thanks,
Peter