1.
FirstTime is true if the activity is created the first time for this process. Variables in Globals get initialized every time the activity is created. So if the device is rotated the activity get recreated and so the sql1 variable will be dimmed again. But it will then not be initialized again because the process is still running and FirstTime will be false in this case.
2.
The service will be started one hour in the future. The problem is that the system may decide to kick the process out of memory in this time but the service will still start at the given time. So when the service starts there is a chance that the sql1 variable isn't initialized anymore.
3.
This is quite similar to the 1st problem. The layout only gets loaded if the activity wasn't created for this process. If you rotate the device the process keeps running, FirstTime is false and the layout does not load. The system may even decide to kill an activity if it is not visible and the problem can occur if you just start another app and you bring this activity to front after some time.
4.
The Msgbox waits until the user closes it. This is a bad thing in Activity_Pause, Activity_Resume etc. because you will get an ANR (Application Not Responding) error.
Haven't tried the code snippets. Just my thoughts about it.
The answers should be put into some form of FAQ.
Edit:
See the additional comments from Erel in post #4
Additional comment for 2.
In addition to Erels comment in #4 the same problem can happen with two Activities. The Main Activity is not always called when the process and another activity gets created. Be sure to make all your necessary (global) initializations in Activity_Create() of EVERY Activity and Service_Create() in EVERY service module.