FirstTime is executed several times

edgar_ortiz

Active Member
Licensed User
Longtime User
Hi...
I figure that I'm doing something wrong... what is... I don't know :BangHead::BangHead:

HTML:
pk   programa   fecha_hora   info   pk_envio   fecha_hora_envio
1   Main.Create.FirstTime   2013-02-14 21:17:00   DataBase Opened   0   
2   Service.GPS   2013-02-14 21:17:00   Service_Create   0   
3   Service.GPS   2013-02-14 21:17:01   Service_Start   0   
4   Service.GPS   2013-02-14 21:17:01   Stop previos GPS   0   
5   Service.GPS   2013-02-14 21:17:01   Next Schedule : 2013-02-14 21:20:01   0   
6   Service.GPS   2013-02-14 21:17:01   GPS Start   0   
7   Service.GPS   2013-02-14 21:17:01   Start without filters   0   
8   Service.GPS   2013-02-14 21:19:24   Begin of LocationChanged   0   
9   Service.GPS   2013-02-14 21:19:24   MORE than one minute   0   
10   Service.GPS   2013-02-14 21:19:24   Lat: 16.92852232634678 Long: -89.89083758650204   0   
11   Service.GPS   2013-02-14 21:19:25   Store in Data Base   0   
12   Service.GPS   2013-02-14 21:19:25   End of Store in Data Base   0   
13   Service.GPS   2013-02-14 21:19:25   End of LocationChanged   0   
14   Service.GPS   2013-02-14 21:19:25   Service Destroy   0   
15   Service.GPS   2013-02-14 21:20:01   Service_Create   0   
16   Service.GPS   2013-02-14 21:20:01   Service_Start   0   
17   Service.GPS   2013-02-14 21:20:01   Stop previos GPS   0   
18   Service.GPS   2013-02-14 21:20:01   Next Schedule : 2013-02-14 21:23:01   0   
19   Service.GPS   2013-02-14 21:20:01   GPS Start   0   
20   Service.GPS   2013-02-14 21:20:01   Start without filters   0   
21   Service.GPS   2013-02-14 21:20:04   Begin of LocationChanged   0   
22   Service.GPS   2013-02-14 21:20:04   LESS than one minute (do nothing)   0   
23   Service.GPS   2013-02-14 21:20:04   End of LocationChanged   0   
24   Service.GPS   2013-02-14 21:20:04   Service Destroy   0   
25   Service.GPS   2013-02-14 21:23:01   Service_Create   0   
26   Service.GPS   2013-02-14 21:23:02   Service_Start   0   
27   Service.GPS   2013-02-14 21:23:02   Stop previos GPS   0   
28   Service.GPS   2013-02-14 21:23:02   Next Schedule : 2013-02-14 21:26:02   0   
29   Service.GPS   2013-02-14 21:23:02   GPS Start   0   
30   Service.GPS   2013-02-14 21:23:02   Start without filters   0   
31   Service.GPS   2013-02-14 21:23:16   Begin of LocationChanged   0   
32   Service.GPS   2013-02-14 21:23:16   MORE than one minute   0   
33   Service.GPS   2013-02-14 21:23:16   Lat: 16.92888479968881 Long: -89.89128222458518   0   
34   Service.GPS   2013-02-14 21:23:16   Store in Data Base   0   
35   Service.GPS   2013-02-14 21:23:16   End of Store in Data Base   0   
36   Service.GPS   2013-02-14 21:23:16   End of LocationChanged   0   
37   Service.GPS   2013-02-14 21:23:16   Service Destroy   0   
38   Service.GPS   2013-02-14 21:26:02   Service_Create   0   
39   Service.GPS   2013-02-14 21:26:03   Service_Start   0   
40   Service.GPS   2013-02-14 21:26:03   Stop previos GPS   0   
41   Service.GPS   2013-02-14 21:26:03   Next Schedule : 2013-02-14 21:29:03   0   
42   Service.GPS   2013-02-14 21:26:03   GPS Start   0   
43   Service.GPS   2013-02-14 21:26:03   Start without filters   0   
44   Service.GPS   2013-02-14 21:26:13   Begin of LocationChanged   0   
45   Service.GPS   2013-02-14 21:26:13   MORE than one minute   0   
46   Service.GPS   2013-02-14 21:26:13   Lat: 16.92861456008283 Long: -89.89150431044959   0   
47   Service.GPS   2013-02-14 21:26:13   Store in Data Base   0   
48   Service.GPS   2013-02-14 21:26:13   End of Store in Data Base   0   
49   Service.GPS   2013-02-14 21:26:14   End of LocationChanged   0   
50   Service.GPS   2013-02-14 21:26:14   Service Destroy   0   
51   Service.GPS   2013-02-14 21:29:03   Service_Create   0   
52   Service.GPS   2013-02-14 21:29:04   Service_Start   0   
53   Service.GPS   2013-02-14 21:29:04   Stop previos GPS   0   
54   Service.GPS   2013-02-14 21:29:04   Next Schedule : 2013-02-14 21:32:04   0   
55   Service.GPS   2013-02-14 21:29:04   GPS Start   0   
56   Service.GPS   2013-02-14 21:29:04   Start without filters   0   
57   Service.GPS   2013-02-14 21:29:15   Begin of LocationChanged   0   
58   Service.GPS   2013-02-14 21:29:15   MORE than one minute   0   
59   Service.GPS   2013-02-14 21:29:16   Lat: 16.928467046026828 Long: -89.89128991280153   0   
60   Service.GPS   2013-02-14 21:29:16   Store in Data Base   0   
61   Service.GPS   2013-02-14 21:29:16   End of Store in Data Base   0   
62   Service.GPS   2013-02-14 21:29:16   End of LocationChanged   0   
63   Service.GPS   2013-02-14 21:29:16   Service Destroy   0   
64   Service.GPS   2013-02-14 21:32:04   Service_Create   0   
65   Service.GPS   2013-02-14 21:32:05   Service_Start   0   
66   Service.GPS   2013-02-14 21:32:05   Stop previos GPS   0   
67   Service.GPS   2013-02-14 21:32:05   Next Schedule : 2013-02-14 21:35:05   0   
68   Service.GPS   2013-02-14 21:32:05   GPS Start   0   
69   Service.GPS   2013-02-14 21:32:05   Start without filters   0   
70   Service.GPS   2013-02-14 21:32:15   Begin of LocationChanged   0   
71   Service.GPS   2013-02-14 21:32:15   MORE than one minute   0   
72   Service.GPS   2013-02-14 21:32:15   Lat: 16.92887384136045 Long: -89.89110461821707   0   
73   Service.GPS   2013-02-14 21:32:15   Store in Data Base   0   
74   Service.GPS   2013-02-14 21:32:16   End of Store in Data Base   0   
75   Service.GPS   2013-02-14 21:32:16   End of LocationChanged   0   
76   Service.GPS   2013-02-14 21:32:16   Service Destroy   0   
77   Main.Create.FirstTime   2013-02-14 21:33:24   DataBase Opened   0   
78   Service.GPS   2013-02-14 21:33:25   Service_Create   0   
79   Service.GPS   2013-02-14 21:33:25   Service_Start   0   
80   Service.GPS   2013-02-14 21:33:25   Stop previos GPS   0   
81   Service.GPS   2013-02-14 21:33:25   Next Schedule : 2013-02-14 21:36:25   0   
82   Service.GPS   2013-02-14 21:33:25   GPS Start   0   
83   Service.GPS   2013-02-14 21:33:25   Start without filters   0   
84   Service.GPS   2013-02-14 21:33:26   Begin of LocationChanged   0   
85   Service.GPS   2013-02-14 21:33:26   MORE than one minute   0   
86   Service.GPS   2013-02-14 21:33:26   Lat: 16.928848183350148 Long: -89.89127268911521   0   
87   Service.GPS   2013-02-14 21:33:26   Store in Data Base   0   
88   Service.GPS   2013-02-14 21:33:27   End of Store in Data Base   0   
89   Service.GPS   2013-02-14 21:33:27   End of LocationChanged   0   
90   Service.GPS   2013-02-14 21:33:27   Service Destroy   0   
91   Service.GPS   2013-02-14 21:36:25   Service_Create   0   
92   Service.GPS   2013-02-14 21:36:25   Service_Start   0   
93   Service.GPS   2013-02-14 21:36:26   Stop previos GPS   0   
94   Service.GPS   2013-02-14 21:36:26   Next Schedule : 2013-02-14 21:39:26   0   
95   Service.GPS   2013-02-14 21:36:26   GPS Start   0   
96   Service.GPS   2013-02-14 21:36:26   Start without filters   0   
97   Service.GPS   2013-02-14 21:39:26   Service_Start   0   
98   Service.GPS   2013-02-14 21:39:26   Stop previos GPS   0   
99   Service.GPS   2013-02-14 21:39:26   Next Schedule : 2013-02-14 21:42:26   0   
100   Service.GPS   2013-02-14 21:39:27   GPS Start   0   
101   Service.GPS   2013-02-14 21:39:27   Start without filters   0   
102   Service.GPS   2013-02-14 21:39:52   Begin of LocationChanged   0   
103   Service.GPS   2013-02-14 21:39:52   MORE than one minute   0   
104   Service.GPS   2013-02-14 21:39:52   Lat: 16.929218584132933 Long: -89.89226157266113   0   
105   Service.GPS   2013-02-14 21:39:52   Store in Data Base   0   
106   Service.GPS   2013-02-14 21:39:52   End of Store in Data Base   0   
107   Service.GPS   2013-02-14 21:39:52   End of LocationChanged   0   
108   Service.GPS   2013-02-14 21:39:52   Service Destroy   0   
109   Main.Exit   2013-02-14 21:40:19   Trying to exit   0   
110   Main.Exit   2013-02-14 21:40:21   User responde YES to exit   0   
111   Main.Exit   2013-02-14 21:40:21   Current Time :21   0   
112   Main.Exit   2013-02-14 21:40:21   SysGPSBeginHour :8   0   
113   Main.Exit   2013-02-14 21:40:21   SysGPSEndHour :22   0   
114   Main.Exit   2013-02-14 21:40:21   Keep Service running   0   
115   Main.Exit   2013-02-14 21:40:25   Trying to exit   0   
116   Main.Exit   2013-02-14 21:40:26   User say NO to exit   0   
117   Main.Exit   2013-02-14 21:40:28   Trying to exit   0   
118   Main.Exit   2013-02-14 21:40:29   User responde YES to exit   0   
119   Main.Exit   2013-02-14 21:40:29   Current Time :21   0   
120   Main.Exit   2013-02-14 21:40:29   SysGPSBeginHour :8   0   
121   Main.Exit   2013-02-14 21:40:29   SysGPSEndHour :22   0   
122   Main.Exit   2013-02-14 21:40:29   Keep Service running   0   
123   Service.GPS   2013-02-14 21:42:26   Service_Create   0   
124   Service.GPS   2013-02-14 21:42:27   Service_Start   0   
125   Service.GPS   2013-02-14 21:42:27   Stop previos GPS   0   
126   Service.GPS   2013-02-14 21:42:27   Next Schedule : 2013-02-14 21:45:27   0   
127   Service.GPS   2013-02-14 21:42:27   GPS Start   0   
128   Service.GPS   2013-02-14 21:42:27   Start without filters   0   
129   Service.GPS   2013-02-14 21:43:15   Begin of LocationChanged   0   
130   Service.GPS   2013-02-14 21:43:16   MORE than one minute   0   
131   Service.GPS   2013-02-14 21:43:16   Lat: 16.929385036736445 Long: -89.89225662021977   0   
132   Service.GPS   2013-02-14 21:43:16   Store in Data Base   0   
133   Service.GPS   2013-02-14 21:43:16   End of Store in Data Base   0   
134   Service.GPS   2013-02-14 21:43:16   End of LocationChanged   0   
135   Service.GPS   2013-02-14 21:43:16   Service Destroy   0   
136   Service.GPS   2013-02-14 21:45:27   Service_Create   0   
137   Service.GPS   2013-02-14 21:45:28   Service_Start   0   
138   Service.GPS   2013-02-14 21:45:28   Stop previos GPS   0   
139   Service.GPS   2013-02-14 21:45:28   Next Schedule : 2013-02-14 21:48:28   0   
140   Service.GPS   2013-02-14 21:45:28   GPS Start   0   
141   Service.GPS   2013-02-14 21:45:28   Start without filters   0   
142   Service.GPS   2013-02-14 21:45:37   Begin of LocationChanged   0   
143   Service.GPS   2013-02-14 21:45:37   MORE than one minute   0   
144   Service.GPS   2013-02-14 21:45:37   Lat: 16.929313715453574 Long: -89.8919881568446   0   
145   Service.GPS   2013-02-14 21:45:37   Store in Data Base   0   
146   Service.GPS   2013-02-14 21:45:37   End of Store in Data Base   0   
147   Service.GPS   2013-02-14 21:45:37   End of LocationChanged   0   
148   Service.GPS   2013-02-14 21:45:37   Service Destroy   0   
149   Service.GPS   2013-02-14 21:48:28   Service_Create   0   
150   Service.GPS   2013-02-14 21:48:29   Service_Start   0   
151   Service.GPS   2013-02-14 21:48:29   Stop previos GPS   0   
152   Service.GPS   2013-02-14 21:48:29   Next Schedule : 2013-02-14 21:51:29   0   
153   Service.GPS   2013-02-14 21:48:29   GPS Start   0   
154   Service.GPS   2013-02-14 21:48:29   Start without filters   0   
155   Service.GPS   2013-02-14 21:48:35   Begin of LocationChanged   0   
156   Service.GPS   2013-02-14 21:48:35   MORE than one minute   0   
157   Service.GPS   2013-02-14 21:48:36   Lat: 16.929449621524956 Long: -89.8925015315048   0   
158   Service.GPS   2013-02-14 21:48:36   Store in Data Base   0   
159   Service.GPS   2013-02-14 21:48:36   End of Store in Data Base   0   
160   Service.GPS   2013-02-14 21:48:36   End of LocationChanged   0   
161   Service.GPS   2013-02-14 21:48:36   Service Destroy   0   
162   Service.GPS   2013-02-14 21:51:29   Service_Create   0   
163   Service.GPS   2013-02-14 21:51:30   Service_Start   0   
164   Service.GPS   2013-02-14 21:51:30   Stop previos GPS   0   
165   Service.GPS   2013-02-14 21:51:30   Next Schedule : 2013-02-14 21:54:30   0   
166   Service.GPS   2013-02-14 21:51:30   GPS Start   0   
167   Service.GPS   2013-02-14 21:51:30   Start without filters   0   
168   Service.GPS   2013-02-14 21:51:55   Begin of LocationChanged   0   
169   Service.GPS   2013-02-14 21:51:56   MORE than one minute   0   
170   Service.GPS   2013-02-14 21:51:56   Lat: 16.929868386566202 Long: -89.89254258229353   0   
171   Service.GPS   2013-02-14 21:51:56   Store in Data Base   0   
172   Service.GPS   2013-02-14 21:51:56   End of Store in Data Base   0   
173   Service.GPS   2013-02-14 21:51:56   End of LocationChanged   0   
174   Service.GPS   2013-02-14 21:51:56   Service Destroy   0   
175   Main.Create.FirstTime   2013-02-14 21:53:46   DataBase Opened   0   
176   Service.GPS   2013-02-14 21:53:47   Service_Create   0   
177   Service.GPS   2013-02-14 21:53:47   Service_Start   0   
178   Service.GPS   2013-02-14 21:53:47   Stop previos GPS   0   
179   Service.GPS   2013-02-14 21:53:47   Next Schedule : 2013-02-14 21:56:47   0   
180   Service.GPS   2013-02-14 21:53:48   GPS Start   0   
181   Service.GPS   2013-02-14 21:53:48   Start without filters   0   
182   Service.GPS   2013-02-14 21:53:57   Begin of LocationChanged   0   
183   Service.GPS   2013-02-14 21:53:57   MORE than one minute   0   
184   Service.GPS   2013-02-14 21:53:57   Lat: 16.929466486781678 Long: -89.89221719424059   0   
185   Service.GPS   2013-02-14 21:53:57   Store in Data Base   0   
186   Service.GPS   2013-02-14 21:53:57   End of Store in Data Base   0   
187   Service.GPS   2013-02-14 21:53:57   End of LocationChanged   0   
188   Service.GPS   2013-02-14 21:53:57   Service Destroy   0   
189   Service.GPS   2013-02-14 21:56:47   Service_Create   0   
190   Service.GPS   2013-02-14 21:56:48   Service_Start   0   
191   Service.GPS   2013-02-14 21:56:48   Stop previos GPS   0   
192   Service.GPS   2013-02-14 21:56:48   Next Schedule : 2013-02-14 21:59:48   0   
193   Service.GPS   2013-02-14 21:56:48   GPS Start   0   
194   Service.GPS   2013-02-14 21:56:48   Start without filters   0   
195   Service.GPS   2013-02-14 21:57:46   Begin of LocationChanged   0   
196   Service.GPS   2013-02-14 21:57:46   MORE than one minute   0   
197   Service.GPS   2013-02-14 21:57:46   Lat: 16.929158313949976 Long: -89.8932288590994   0   
198   Service.GPS   2013-02-14 21:57:46   Store in Data Base   0   
199   Service.GPS   2013-02-14 21:57:46   End of Store in Data Base   0   
200   Service.GPS   2013-02-14 21:57:46   End of LocationChanged   0   
201   Service.GPS   2013-02-14 21:57:46   Service Destroy   0   
202   Service.GPS   2013-02-14 21:59:48   Service_Create   0   
203   Service.GPS   2013-02-14 21:59:49   Service_Start   0   
204   Service.GPS   2013-02-14 21:59:49   Stop previos GPS   0   
205   Service.GPS   2013-02-14 21:59:49   Next Schedule : 2013-02-14 22:02:49   0   
206   Service.GPS   2013-02-14 21:59:49   GPS Start   0   
207   Service.GPS   2013-02-14 21:59:49   Start without filters   0   
208   Service.GPS   2013-02-14 22:00:04   Begin of LocationChanged   0   
209   Service.GPS   2013-02-14 22:00:04   MORE than one minute   0   
210   Service.GPS   2013-02-14 22:00:04   Lat: 16.929343560703554 Long: -89.89277918806577   0   
211   Service.GPS   2013-02-14 22:00:04   Store in Data Base   0   
212   Service.GPS   2013-02-14 22:00:04   End of Store in Data Base   0   
213   Service.GPS   2013-02-14 22:00:04   End of LocationChanged   0   
214   Service.GPS   2013-02-14 22:00:04   Service Destroy   0   
215   Service.GPS   2013-02-14 22:02:49   Service_Create   0   
216   Service.GPS   2013-02-14 22:02:50   Service_Start   0   
217   Service.GPS   2013-02-14 22:02:50   Stop previos GPS   0   
218   Service.GPS   2013-02-14 22:02:50   Next Schedule : 2013-02-14 22:05:50   0   
219   Service.GPS   2013-02-14 22:02:50   GPS Start   0   
220   Service.GPS   2013-02-14 22:02:50   Start without filters   0   
221   Service.GPS   2013-02-14 22:04:29   Begin of LocationChanged   0   
222   Service.GPS   2013-02-14 22:04:29   MORE than one minute   0   
223   Service.GPS   2013-02-14 22:04:29   Lat: 16.931197760517975 Long: -89.89102977222876   0   
224   Service.GPS   2013-02-14 22:04:30   Store in Data Base   0   
225   Service.GPS   2013-02-14 22:04:30   End of Store in Data Base   0   
226   Service.GPS   2013-02-14 22:04:30   End of LocationChanged   0   
227   Service.GPS   2013-02-14 22:04:30   Service Destroy   0   
228   Service.GPS   2013-02-14 22:05:50   Service_Create   0   
229   Service.GPS   2013-02-14 22:05:50   Service_Start   0   
230   Service.GPS   2013-02-14 22:05:50   Stop previos GPS   0   
231   Service.GPS   2013-02-14 22:05:50   Next Schedule : 2013-02-14 22:08:50   0   
232   Service.GPS   2013-02-14 22:05:50   GPS Start   0   
233   Service.GPS   2013-02-14 22:05:50   Start without filters   0   
234   Service.GPS   2013-02-14 22:06:58   Begin of LocationChanged   0   
235   Service.GPS   2013-02-14 22:06:58   MORE than one minute   0   
236   Service.GPS   2013-02-14 22:06:58   Lat: 16.929141230558635 Long: -89.89290829709223   0   
237   Service.GPS   2013-02-14 22:06:58   Store in Data Base   0   
238   Service.GPS   2013-02-14 22:06:58   End of Store in Data Base   0   
239   Service.GPS   2013-02-14 22:06:58   End of LocationChanged   0   
240   Service.GPS   2013-02-14 22:06:58   Service Destroy   0   
241   Service.GPS   2013-02-14 22:08:50   Service_Create   0   
242   Service.GPS   2013-02-14 22:08:51   Service_Start   0   
243   Service.GPS   2013-02-14 22:08:51   Stop previos GPS   0   
244   Service.GPS   2013-02-14 22:08:51   Next Schedule : 2013-02-14 22:11:51   0   
245   Service.GPS   2013-02-14 22:08:51   GPS Start   0   
246   Service.GPS   2013-02-14 22:08:51   Start without filters   0   
247   Service.GPS   2013-02-14 22:09:12   Begin of LocationChanged   0   
248   Service.GPS   2013-02-14 22:09:13   MORE than one minute   0   
249   Service.GPS   2013-02-14 22:09:13   Lat: 16.929505766642162 Long: -89.8920001120564   0   
250   Service.GPS   2013-02-14 22:09:13   Store in Data Base   0   
251   Service.GPS   2013-02-14 22:09:13   End of Store in Data Base   0   
252   Service.GPS   2013-02-14 22:09:13   End of LocationChanged   0   
253   Service.GPS   2013-02-14 22:09:13   Service Destroy   0   
254   Service.GPS   2013-02-14 22:11:51   Service_Create   0   
255   Service.GPS   2013-02-14 22:11:52   Service_Start   0   
256   Service.GPS   2013-02-14 22:11:52   Stop previos GPS   0   
257   Service.GPS   2013-02-14 22:11:52   Next Schedule : 2013-02-14 22:14:52   0   
258   Service.GPS   2013-02-14 22:11:52   GPS Start   0   
259   Service.GPS   2013-02-14 22:11:52   Start without filters   0   
260   Service.GPS   2013-02-14 22:12:15   Begin of LocationChanged   0   
261   Service.GPS   2013-02-14 22:12:15   MORE than one minute   0   
262   Service.GPS   2013-02-14 22:12:16   Lat: 16.92941546456238 Long: -89.89219964052792   0   
263   Service.GPS   2013-02-14 22:12:16   Store in Data Base   0   
264   Service.GPS   2013-02-14 22:12:16   End of Store in Data Base   0   
265   Service.GPS   2013-02-14 22:12:16   End of LocationChanged   0   
266   Service.GPS   2013-02-14 22:12:16   Service Destroy   0   
267   Service.GPS   2013-02-14 22:14:52   Service_Create   0   
268   Service.GPS   2013-02-14 22:14:53   Service_Start   0   
269   Service.GPS   2013-02-14 22:14:53   Stop previos GPS   0   
270   Service.GPS   2013-02-14 22:14:53   Next Schedule : 2013-02-14 22:17:53   0   
271   Service.GPS   2013-02-14 22:14:53   GPS Start   0   
272   Service.GPS   2013-02-14 22:14:53   Start without filters   0   
273   Service.GPS   2013-02-14 22:16:11   Begin of LocationChanged   0   
274   Service.GPS   2013-02-14 22:16:11   MORE than one minute   0   
275   Service.GPS   2013-02-14 22:16:11   Lat: 16.92972743695892 Long: -89.89205942359628   0   
276   Service.GPS   2013-02-14 22:16:11   Store in Data Base   0   
277   Service.GPS   2013-02-14 22:16:11   End of Store in Data Base   0   
278   Service.GPS   2013-02-14 22:16:11   End of LocationChanged   0   
279   Service.GPS   2013-02-14 22:16:11   Service Destroy   0   
280   Service.GPS   2013-02-14 22:17:53   Service_Create   0   
281   Service.GPS   2013-02-14 22:17:53   Service_Start   0   
282   Service.GPS   2013-02-14 22:17:54   Stop previos GPS   0   
283   Service.GPS   2013-02-14 22:17:54   Next Schedule : 2013-02-14 22:20:54   0   
284   Service.GPS   2013-02-14 22:17:54   GPS Start   0   
285   Service.GPS   2013-02-14 22:17:54   Start without filters   0   
286   Service.GPS   2013-02-14 22:18:58   Begin of LocationChanged   0   
287   Service.GPS   2013-02-14 22:18:58   MORE than one minute   0   
288   Service.GPS   2013-02-14 22:18:58   Lat: 16.92895432976297 Long: -89.8914779492052   0   
289   Service.GPS   2013-02-14 22:18:58   Store in Data Base   0   
290   Service.GPS   2013-02-14 22:18:58   End of Store in Data Base   0   
291   Service.GPS   2013-02-14 22:18:58   End of LocationChanged   0   
292   Service.GPS   2013-02-14 22:18:58   Service Destroy   0   
293   Service.GPS   2013-02-14 22:20:54   Service_Create   0   
294   Service.GPS   2013-02-14 22:20:54   Service_Start   0   
295   Service.GPS   2013-02-14 22:20:54   Stop previos GPS   0   
296   Service.GPS   2013-02-14 22:20:54   Next Schedule : 2013-02-14 22:23:54   0   
297   Service.GPS   2013-02-14 22:20:54   GPS Start   0   
298   Service.GPS   2013-02-14 22:20:54   Start without filters   0   
299   Service.GPS   2013-02-14 22:23:54   Service_Start   0   
300   Service.GPS   2013-02-14 22:23:54   Stop previos GPS   0   
301   Service.GPS   2013-02-14 22:23:54   Next Schedule : 2013-02-14 22:26:54   0   
302   Service.GPS   2013-02-14 22:23:55   GPS Start   0   
303   Service.GPS   2013-02-14 22:23:55   Start without filters   0   
304   Service.GPS   2013-02-14 22:26:30   Begin of LocationChanged   0   
305   Service.GPS   2013-02-14 22:26:30   MORE than one minute   0   
306   Service.GPS   2013-02-14 22:26:30   Lat: 16.93009607533942 Long: -89.89168024432766   0   
307   Service.GPS   2013-02-14 22:26:30   Store in Data Base   0   
308   Service.GPS   2013-02-14 22:26:30   End of Store in Data Base   0   
309   Service.GPS   2013-02-14 22:26:30   End of LocationChanged   0   
310   Service.GPS   2013-02-14 22:26:30   Service Destroy   0   
311   Service.GPS   2013-02-14 22:26:54   Service_Create   0   
312   Service.GPS   2013-02-14 22:26:54   Service_Start   0   
313   Service.GPS   2013-02-14 22:26:55   Stop previos GPS   0   
314   Service.GPS   2013-02-14 22:26:55   Next Schedule : 2013-02-14 22:29:55   0   
315   Service.GPS   2013-02-14 22:26:55   GPS Start   0   
316   Service.GPS   2013-02-14 22:26:55   Start without filters   0   
317   Service.GPS   2013-02-14 22:28:31   Begin of LocationChanged   0   
318   Service.GPS   2013-02-14 22:28:31   MORE than one minute   0   
319   Service.GPS   2013-02-14 22:28:31   Lat: 16.92930438676159 Long: -89.89225479699675   0   
320   Service.GPS   2013-02-14 22:28:31   Store in Data Base   0   
321   Service.GPS   2013-02-14 22:28:31   End of Store in Data Base   0   
322   Service.GPS   2013-02-14 22:28:31   End of LocationChanged   0   
323   Service.GPS   2013-02-14 22:28:31   Service Destroy   0   
324   Service.GPS   2013-02-14 22:29:55   Service_Create   0   
325   Service.GPS   2013-02-14 22:29:55   Service_Start   0   
326   Service.GPS   2013-02-14 22:29:55   Stop previos GPS   0   
327   Service.GPS   2013-02-14 22:29:55   Next Schedule : 2013-02-14 22:32:55   0   
328   Service.GPS   2013-02-14 22:29:55   GPS Start   0   
329   Service.GPS   2013-02-14 22:29:55   Start without filters   0   
330   Service.GPS   2013-02-14 22:32:55   Service_Start   0   
331   Service.GPS   2013-02-14 22:32:55   Stop previos GPS   0   
332   Service.GPS   2013-02-14 22:32:55   Next Schedule : 2013-02-14 22:35:55   0   
333   Service.GPS   2013-02-14 22:32:55   GPS Start   0   
334   Service.GPS   2013-02-14 22:32:55   Start without filters   0   
335   Service.GPS   2013-02-14 22:34:09   Begin of LocationChanged   0   
336   Service.GPS   2013-02-14 22:34:09   MORE than one minute   0   
337   Service.GPS   2013-02-14 22:34:09   Lat: 16.929430247468428 Long: -89.89233966429984   0   
338   Service.GPS   2013-02-14 22:34:10   Store in Data Base   0   
339   Service.GPS   2013-02-14 22:34:10   End of Store in Data Base   0   
340   Service.GPS   2013-02-14 22:34:10   End of LocationChanged   0   
341   Service.GPS   2013-02-14 22:34:10   Service Destroy   0   
342   Main.Create.FirstTime   2013-02-15 00:10:54   DataBase Opened   0   
343   Service.GPS   2013-02-15 00:10:55   Service_Create   0   
344   Service.GPS   2013-02-15 00:10:55   Service_Start   0   
345   Service.GPS   2013-02-15 00:10:55   Do Not Schedule   0   
346   Service.GPS   2013-02-15 00:10:55   Actual Time :0   0   
347   Service.GPS   2013-02-15 00:10:55   SysGPSBeginHour :8   0   
348   Service.GPS   2013-02-15 00:10:55   SysGPSEndHour :22   0   
349   Service.GPS   2013-02-15 00:10:55   GPS Start   0   
350   Service.GPS   2013-02-15 00:10:55   Start without filters   0   
351   Service.GPS   2013-02-15 00:11:09   Begin of LocationChanged   0   
352   Service.GPS   2013-02-15 00:11:09   MORE than one minute   0   
353   Service.GPS   2013-02-15 00:11:09   Lat: 16.92912284548835 Long: -89.89108673188345   0   
354   Service.GPS   2013-02-15 00:11:09   Store in Data Base   0   
355   Service.GPS   2013-02-15 00:11:09   End of Store in Data Base   0   
356   Service.GPS   2013-02-15 00:11:09   End of LocationChanged   0   
357   Service.GPS   2013-02-15 00:11:09   Service Destroy   0   
358   Main.Force_Exit   2013-02-15 00:11:31   Trying to Force Exit   0   
359   Main.Force_Exit   2013-02-15 00:11:32   User responde YES to force exit   0   
360   Main.Force_Exit   2013-02-15 00:11:33   Exit Aplication   0

Any help is welcome

You can see in the log that FirstTime is executed several times (line:1,77,175,342)


Regards

Edgar
 

Attachments

  • Gps_Test_20130218.zip
    69.5 KB · Views: 141
Last edited:

edgar_ortiz

Active Member
Licensed User
Longtime User
Thanks for your time,

problem is that it is running the program TWICE.

In fact, I need click twice the button "force exit"

Any help is welcome

HTML:
2013-02-15 13:20:27 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-15 13:20:27', 'End of Store in Data Base')
2013-02-15 13:20:27 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-15 13:20:27', 'End of LocationChanged')
** Service (gps) Destroy **
2013-02-15 13:20:27 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-15 13:20:27', 'Service Destroy')
** Activity (main) Create, isFirst = true **
FistTime is executed
Rutinas.Open_DataBase -- Database is Open
2013-02-15 13:22:21 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Main.Create.FirstTime','2013-02-15 13:22:21', 'DataBase Opened')
** Activity (main) Resume **
** Service (gps) Create **
2013-02-15 13:22:22 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-15 13:22:22', 'Service_Create')
** Service (gps) Start **
2013-02-15 13:22:22 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-15 13:22:22', 'Service_Start')
2013-02-15 13:22:22 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-15 13:22:22', 'Stop previos GPS')
2013-02-15 13:22:22 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-15 13:22:22', 'Next Schedule : 2013-02-15 13:25:22')
2013-02-15 13:22:22 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-15 13:22:22', 'GPS Start')
2013-02-15 13:22:22 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-15 13:22:22', 'Start without filters')
2013-02-15 13:22:30 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-15 13:22:30', 'Begin of LocationChanged')
2013-02-15 13:22:30 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-15 13:22:30', 'MORE than one minute')
2013-02-15 13:22:30 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-15 13:22:30', 'Lat: 16.92872859646252 Long: -89.89102057937119')
2013-02-15 13:22:30 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-15 13:22:30', 'Store in Data Base')
2013-02-15 13:22:30 Before of Store_In_Data_Base: INSERT INTO sg_t_gps (fecha_hora, latitud, longitud, direccion, velocidad, altitud, precision, estado_gps, fecha_hora_envio) values ('2013-02-15 13:22:30', '16.92872859646252', '-89.89102057937119', '0', '0', '66', '40', 'A', '2013-02-15 13:25:22')
2013-02-15 13:22:30 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-15 13:22:30', 'End of Store in Data Base')
2013-02-15 13:22:30 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-15 13:22:30', 'End of LocationChanged')
** Service (gps) Destroy **
2013-02-15 13:22:30 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-15 13:22:30', 'Service Destroy')
2013-02-15 13:22:37 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Main.Exit','2013-02-15 13:22:37', 'Trying to exit')
2013-02-15 13:22:40 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Main.Exit','2013-02-15 13:22:40', 'User say NO to exit')
2013-02-15 13:22:42 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Main.Force_Exit','2013-02-15 13:22:42', 'Trying to Force Exit')
2013-02-15 13:22:44 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Main.Force_Exit','2013-02-15 13:22:44', 'User responde YES to force exit')
2013-02-15 13:22:44 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Main.Force_Exit','2013-02-15 13:22:44', 'Exit Aplication')
Main.Force_Exit - Exit Aplication
** Activity (main) Create, isFirst = true **
FistTime is executed
Rutinas.Open_DataBase -- Database is Open
2013-02-15 13:22:44 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Main.Create.FirstTime','2013-02-15 13:22:44', 'DataBase Opened')
** Activity (main) Resume **
** Service (gps) Create **
2013-02-15 13:22:44 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-15 13:22:44', 'Service_Create')
** Service (gps) Start **
2013-02-15 13:22:44 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-15 13:22:44', 'Service_Start')
2013-02-15 13:22:44 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-15 13:22:44', 'Stop previos GPS')
2013-02-15 13:22:44 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-15 13:22:44', 'Next Schedule : 2013-02-15 13:25:44')
2013-02-15 13:22:44 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-15 13:22:44', 'GPS Start')
2013-02-15 13:22:44 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-15 13:22:44', 'Start without filters')
2013-02-15 13:22:45 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-15 13:22:45', 'Begin of LocationChanged')
2013-02-15 13:22:45 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-15 13:22:45', 'MORE than one minute')
2013-02-15 13:22:45 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-15 13:22:45', 'Lat: 16.928583502715522 Long: -89.89107066510319')
2013-02-15 13:22:46 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-15 13:22:46', 'Store in Data Base')
2013-02-15 13:22:46 Before of Store_In_Data_Base: INSERT INTO sg_t_gps (fecha_hora, latitud, longitud, direccion, velocidad, altitud, precision, estado_gps, fecha_hora_envio) values ('2013-02-15 13:22:46', '16.928583502715522', '-89.89107066510319', '0', '0', '122', '10', 'A', '2013-02-15 13:25:44')
2013-02-15 13:22:46 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-15 13:22:46', 'End of Store in Data Base')
2013-02-15 13:22:46 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-15 13:22:46', 'End of LocationChanged')
** Service (gps) Destroy **
2013-02-15 13:22:46 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-15 13:22:46', 'Service Destroy')
2013-02-15 13:22:47 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Main.Force_Exit','2013-02-15 13:22:47', 'Trying to Force Exit')
2013-02-15 13:22:48 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Main.Force_Exit','2013-02-15 13:22:48', 'User responde YES to force exit')
2013-02-15 13:22:48 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Main.Force_Exit','2013-02-15 13:22:48', 'Exit Aplication')
Main.Force_Exit - Exit Aplication
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Service (service1) Create **
** Service (service1) Start **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = true **
Connected to B4A-Bridge (Bluetooth)
 
Upvote 0

NJDude

Expert
Licensed User
Longtime User
As thedesolatesoul mentioned above, FirstTime triggers EVERY TIME the app runs for the VERY FIRST TIME, and you might be causing it, on lines #147, #201 and #235 of your Main module you have "ExitApplication" that KILLS the app and all processes, so, the next time you open the app FirstTime will be TRUE.
 
Upvote 0

edgar_ortiz

Active Member
Licensed User
Longtime User
NJDude

Thanks for your time

As thedesolatesoul mentioned above, FirstTime triggers EVERY TIME the app runs for the VERY FIRST TIME, and you might be causing it, on lines #147, #201 and #235 of your Main module you have "ExitApplication" that KILLS the app and all processes, so, the next time you open the app FirstTime will be TRUE.

Yes, that's when i need to EXIT the application... other times, just need to Finish the activity and keep the service running.

HTML:
pk   programa   fecha_hora   info   pk_envio   fecha_hora_envio
1   Main.Create.FirstTime   2013-02-15 15:56:55   DataBase Opened   0   
2   Service.GPS   2013-02-15 15:56:55   Service_Create   0   
3   Service.GPS   2013-02-15 15:56:55   Service_Start   0   
4   Service.GPS   2013-02-15 15:56:55   Stop previos GPS   0   
5   Service.GPS   2013-02-15 15:56:56   Next Schedule : 2013-02-15 15:59:55   0   
6   Service.GPS   2013-02-15 15:56:56   GPS Start   0   
7   Service.GPS   2013-02-15 15:56:56   Start without filters   0   
8   Service.GPS   2013-02-15 15:59:55   Service_Start   0   
9   Service.GPS   2013-02-15 15:59:55   Stop previos GPS   0   
10   Service.GPS   2013-02-15 15:59:56   Next Schedule : 2013-02-15 16:02:55   0   
11   Service.GPS   2013-02-15 15:59:56   GPS Start   0   
12   Service.GPS   2013-02-15 15:59:56   Start without filters   0   
13   Service.GPS   2013-02-15 16:00:02   Begin of LocationChanged   0   
14   Service.GPS   2013-02-15 16:00:02   MORE than one minute   0   
15   Service.GPS   2013-02-15 16:00:02   Lat: 16.928677779927437 Long: -89.89102024420701   0   
16   Service.GPS   2013-02-15 16:00:02   Store in Data Base   0   
17   Service.GPS   2013-02-15 16:00:03   End of Store in Data Base   0   
18   Service.GPS   2013-02-15 16:00:03   End of LocationChanged   0   
19   Service.GPS   2013-02-15 16:00:03   Service Destroy   0   
20   Main.Exit   2013-02-15 16:00:50   Trying to exit   0   
21   Main.Exit   2013-02-15 16:00:56   User respond YES to exit   0   
22   Main.Exit   2013-02-15 16:00:56   Current Hour :16   0   
23   Main.Exit   2013-02-15 16:00:57   SysGPSBeginHour :8   0   
24   Main.Exit   2013-02-15 16:00:57   SysGPSEndHour :22   0   
25   Main.Exit   2013-02-15 16:00:57   Keep Service running   0   
26   Main.Exit   2013-02-15 16:01:09   Trying to exit   0   
27   Main.Exit   2013-02-15 16:01:11   User respond YES to exit   0   
28   Main.Exit   2013-02-15 16:01:11   Current Hour :16   0   
29   Main.Exit   2013-02-15 16:01:11   SysGPSBeginHour :8   0   
30   Main.Exit   2013-02-15 16:01:11   SysGPSEndHour :22   0   
31   Main.Exit   2013-02-15 16:01:11   Keep Service running   0   
32   Service.GPS   2013-02-15 16:02:56   Service_Create   0   
33   Service.GPS   2013-02-15 16:02:56   Service_Start   0   
34   Service.GPS   2013-02-15 16:02:56   Stop previos GPS   0   
35   Service.GPS   2013-02-15 16:02:56   Next Schedule : 2013-02-15 16:05:56   0   
36   Service.GPS   2013-02-15 16:02:56   GPS Start   0   
37   Service.GPS   2013-02-15 16:02:57   Start without filters   0   
38   Service.GPS   2013-02-15 16:03:18   Begin of LocationChanged   0   
39   Service.GPS   2013-02-15 16:03:18   MORE than one minute   0   
40   Service.GPS   2013-02-15 16:03:18   Lat: 16.928557346378028 Long: -89.89080073377461   0   
41   Service.GPS   2013-02-15 16:03:18   Store in Data Base   0   
42   Service.GPS   2013-02-15 16:03:18   End of Store in Data Base   0   
43   Service.GPS   2013-02-15 16:03:18   End of LocationChanged   0   
44   Service.GPS   2013-02-15 16:03:18   Service Destroy   0   
45   Service.GPS   2013-02-15 16:05:56   Service_Create   0   
46   Service.GPS   2013-02-15 16:05:57   Service_Start   0   
47   Service.GPS   2013-02-15 16:05:57   Stop previos GPS   0   
48   Service.GPS   2013-02-15 16:05:57   Next Schedule : 2013-02-15 16:08:57   0   
49   Service.GPS   2013-02-15 16:05:57   GPS Start   0   
50   Service.GPS   2013-02-15 16:05:57   Start without filters   0   
51   Service.GPS   2013-02-15 16:06:54   Begin of LocationChanged   0   
52   Service.GPS   2013-02-15 16:06:54   MORE than one minute   0   
53   Service.GPS   2013-02-15 16:06:54   Lat: 16.928783086765435 Long: -89.89114752394174   0   
54   Service.GPS   2013-02-15 16:06:54   Store in Data Base   0   
55   Service.GPS   2013-02-15 16:06:54   End of Store in Data Base   0   
56   Service.GPS   2013-02-15 16:06:54   End of LocationChanged   0   
57   Service.GPS   2013-02-15 16:06:54   Service Destroy   0   
58   Main.Create.FirstTime   2013-02-15 16:07:05   DataBase Opened   0   
59   Service.GPS   2013-02-15 16:07:05   Service_Create   0   
60   Service.GPS   2013-02-15 16:07:05   Service_Start   0   
61   Service.GPS   2013-02-15 16:07:05   Stop previos GPS   0   
62   Service.GPS   2013-02-15 16:07:05   Next Schedule : 2013-02-15 16:10:05   0   
63   Service.GPS   2013-02-15 16:07:06   GPS Start   0   
64   Service.GPS   2013-02-15 16:07:06   Start without filters   0   
65   Service.GPS   2013-02-15 16:07:06   Begin of LocationChanged   0   
66   Service.GPS   2013-02-15 16:07:06   MORE than one minute   0   
67   Service.GPS   2013-02-15 16:07:06   Lat: 16.928804395067612 Long: -89.8906740840953   0   
68   Service.GPS   2013-02-15 16:07:06   Store in Data Base   0   
69   Service.GPS   2013-02-15 16:07:06   End of Store in Data Base   0   
70   Service.GPS   2013-02-15 16:07:06   End of LocationChanged   0   
71   Service.GPS   2013-02-15 16:07:06   Service Destroy   0   
72   Service.GPS   2013-02-15 16:10:05   Service_Create   0   
73   Service.GPS   2013-02-15 16:10:05   Service_Start   0   
74   Service.GPS   2013-02-15 16:10:06   Stop previos GPS   0   
75   Service.GPS   2013-02-15 16:10:06   Next Schedule : 2013-02-15 16:13:06   0   
76   Service.GPS   2013-02-15 16:10:06   GPS Start   0   
77   Service.GPS   2013-02-15 16:10:06   Start without filters   0   
78   Main.Force_Exit   2013-02-15 16:11:31   Trying to Force Exit   0   
79   Main.Force_Exit   2013-02-15 16:11:40   User respond YES to force exit   0   
80   Main.Force_Exit   2013-02-15 16:11:40   Exit Aplication   0

I log when call "ExitApplication", but the problem still exists :BangHead:
 
Upvote 0

edgar_ortiz

Active Member
Licensed User
Longtime User
Marget

Thanks for your time.

I took a quick look at your code. Why are you consuming the event after the Activity.Finish. Your are Returning True right after Activity.Finish. I would comment out the Return True and see how it acts.

I fix this error... but the problem still exists:BangHead:
 
Upvote 0

edgar_ortiz

Active Member
Licensed User
Longtime User
Erel,

Thanks for your time.

Not sure that I understand what is the problem. However ExitApplication is problematic as the OS doesn't expect the process to end. You should instead call StopService.

If I don't use a ExitApplication, How "TERMINATE" the application?

In mi code before a ExitApplication, I use:

B4X:
      StopService(GPS)
      ' Cancel previos schedule (if exists)
      CancelScheduledService("GPS")
      DBGPS.Close
      '
      Log("Main.Force_Exit - Exit Aplication")
      '
      ExitApplication

In the end what I need is: The app not end according user desicion and meanwhile is running a process.

Thanks again for your time and any help is welcome.
 
Upvote 0

eps

Expert
Licensed User
Longtime User
Upvote 0

edgar_ortiz

Active Member
Licensed User
Longtime User
eps,

Thanks for your time

I've read the article, I dreamed about it :BangHead:

You don't need to think of the processes as continuing in the background - the OS will flag them and then determine when it needs to halt them - to free up resources needed by other processes.


For me is Ok, that the OS halt my program... the problem is:
WHY FirstTime is executed several times?
and WHY sometimes Variables declared in Process_Globals is missing? http://www.b4x.com/forum/basic4android-updates-questions/26407-variables-declared-process_globals-missing.html
and if I can't use ExitApplication how finish a app?
 
Last edited:
Upvote 0

abner69

Member
Licensed User
Longtime User
Edgar, the force exit button is not needed. The best to do is take the code from the Exit Button and move it to the Activity_Pause - como asi..
B4X:
Sub Activity_Pause (UserClosed As Boolean)
   If UserClosed=True Then
   Dim lcResponse As Int
   Dim lc_Current_Hour   As Int
   '
   lc_Current_Hour   = DateTime.GetHour(DateTime.Now)
   '
   If SysLogEnable = "S" Then
      Rutinas.Write_Log("Main.Exit","Trying to exit")
   End If
   '
   lcResponse = Msgbox2("Sure to Quit?", Activity.Title, "Si", "", "No", Null)   
   If lcResponse = DialogResponse.POSITIVE Then
      '
      If SysLogEnable = "S" Then
         Rutinas.Write_Log("Main.Exit","User respond YES to exit")
         Rutinas.Write_Log("Main.Exit","Current Hour :" & NumberFormat2(lc_Current_Hour,1,0,0,False))
         Rutinas.Write_Log("Main.Exit","SysGPSBeginHour :" & NumberFormat2(SysGPSBeginHour,1,0,0,False))
         Rutinas.Write_Log("Main.Exit","SysGPSEndHour :" & NumberFormat2(SysGPSEndHour,1,0,0,False))
      End If
      '
      If lc_Current_Hour >= SysGPSBeginHour AND lc_Current_Hour <= SysGPSEndHour Then
         '
         If SysLogEnable = "S" Then
            Rutinas.Write_Log("Main.Exit","Keep Service running")
         End If
         '
         ' Just finish the activity, the service keep running
         Activity.Finish
      Else
         '
         If SysLogEnable = "S" Then
            Rutinas.Write_Log("Main.Exit","Exit Aplication")
         End If
         '
         StopService(GPS)
         ' Cancel previos schedule (if exists)
         CancelScheduledService("GPS")
         DBGPS.Close
         '
         Log("Main.Exit - Exit Aplication")
         '
         Activity.Finish
         
      End If
   Else
      Rutinas.Write_Log("Main.Exit","User say NO to exit")
      Return True
   End If
   End If
   
End Sub

and change to this:
B4X:
Sub sgbu_Exit_Click
Activity_Pause(True)

End Sub

you can then remove much code under activity_Keypress too.

on Mine, Activity_Create only executes once when started.


...Pablo
 
Upvote 0

edgar_ortiz

Active Member
Licensed User
Longtime User
Pablo,

Thanks for your time.

I Update the code and NO way :BangHead:

HTML:
Installing file.
PackageAdded: package:test.gps
** Activity (main) Create, isFirst = true **
FistTime is executed
Main.FirstTime -- Database file copied
Rutinas.Open_DataBase -- Database is Open
2013-02-18 18:44:52 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Main.Create.FirstTime','2013-02-18 18:44:52', 'DataBase Opened')
** Activity (main) Resume **
** Service (gps) Create **
2013-02-18 18:44:52 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-18 18:44:52', 'Service_Create')
** Service (gps) Start **
2013-02-18 18:44:52 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-18 18:44:52', 'Service_Start')
2013-02-18 18:44:52 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-18 18:44:52', 'Stop previos GPS')
2013-02-18 18:44:52 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-18 18:44:52', 'Next Schedule : 2013-02-18 18:47:52')
2013-02-18 18:44:53 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-18 18:44:53', 'GPS Start')
2013-02-18 18:44:53 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-18 18:44:53', 'Start without filters')
2013-02-18 18:45:03 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-18 18:45:03', 'Begin of LocationChanged')
2013-02-18 18:45:03 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-18 18:45:03', 'MORE than one minute')
2013-02-18 18:45:03 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-18 18:45:03', 'Lat: 16.928614032407562 Long: -89.8908762587534')
2013-02-18 18:45:03 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-18 18:45:03', 'Store in Data Base')
2013-02-18 18:45:03 Before of Store_In_Data_Base: INSERT INTO sg_t_gps (fecha_hora, latitud, longitud, direccion, velocidad, altitud, precision, estado_gps, fecha_hora_envio) values ('2013-02-18 18:45:03', '16.928614032407562', '-89.8908762587534', '0', '0', '127', '40', 'A', '2013-02-18 18:47:52')
2013-02-18 18:45:03 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-18 18:45:03', 'End of Store in Data Base')
2013-02-18 18:45:04 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-18 18:45:04', 'End of LocationChanged')
** Service (gps) Destroy **
2013-02-18 18:45:04 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-18 18:45:04', 'Service Destroy')
** Activity (main) Pause, UserClosed = false **
** Activity (main) Create, isFirst = false **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (main) Create, isFirst = false **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Service (gps) Create **
2013-02-18 18:47:52 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-18 18:47:52', 'Service_Create')
** Service (gps) Start **
2013-02-18 18:47:53 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-18 18:47:53', 'Service_Start')
2013-02-18 18:47:53 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-18 18:47:53', 'Stop previos GPS')
2013-02-18 18:47:53 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-18 18:47:53', 'Next Schedule : 2013-02-18 18:50:53')
2013-02-18 18:47:53 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-18 18:47:53', 'GPS Start')
2013-02-18 18:47:53 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-18 18:47:53', 'Start without filters')
2013-02-18 18:48:36 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-18 18:48:36', 'Begin of LocationChanged')
2013-02-18 18:48:36 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-18 18:48:36', 'MORE than one minute')
2013-02-18 18:48:36 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-18 18:48:36', 'Lat: 16.929282975887244 Long: -89.89121945319675')
2013-02-18 18:48:37 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-18 18:48:37', 'Store in Data Base')
2013-02-18 18:48:37 Before of Store_In_Data_Base: INSERT INTO sg_t_gps (fecha_hora, latitud, longitud, direccion, velocidad, altitud, precision, estado_gps, fecha_hora_envio) values ('2013-02-18 18:48:37', '16.929282975887244', '-89.89121945319675', '0', '5.015963200349915E-10', '100', '150', 'A', '2013-02-18 18:50:53')
2013-02-18 18:48:37 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-18 18:48:37', 'End of Store in Data Base')
2013-02-18 18:48:37 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-18 18:48:37', 'End of LocationChanged')
** Service (gps) Destroy **
2013-02-18 18:48:37 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-18 18:48:37', 'Service Destroy')
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Service (gps) Create **
2013-02-18 18:50:53 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-18 18:50:53', 'Service_Create')
** Service (gps) Start **
2013-02-18 18:50:53 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-18 18:50:53', 'Service_Start')
2013-02-18 18:50:53 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-18 18:50:53', 'Stop previos GPS')
2013-02-18 18:50:53 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-18 18:50:53', 'Next Schedule : 2013-02-18 18:53:53')
2013-02-18 18:50:53 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-18 18:50:53', 'GPS Start')
2013-02-18 18:50:53 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-18 18:50:53', 'Start without filters')
** Service (gps) Start **
2013-02-18 18:53:53 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-18 18:53:53', 'Service_Start')
2013-02-18 18:53:53 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-18 18:53:53', 'Stop previos GPS')
2013-02-18 18:53:53 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-18 18:53:53', 'Next Schedule : 2013-02-18 18:56:53')
2013-02-18 18:53:53 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-18 18:53:53', 'GPS Start')
2013-02-18 18:53:53 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-18 18:53:53', 'Start without filters')
2013-02-18 18:54:19 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-18 18:54:19', 'Begin of LocationChanged')
2013-02-18 18:54:19 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-18 18:54:19', 'MORE than one minute')
2013-02-18 18:54:20 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-18 18:54:20', 'Lat: 16.928725557154415 Long: -89.89152860131219')
2013-02-18 18:54:20 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-18 18:54:20', 'Store in Data Base')
2013-02-18 18:54:20 Before of Store_In_Data_Base: INSERT INTO sg_t_gps (fecha_hora, latitud, longitud, direccion, velocidad, altitud, precision, estado_gps, fecha_hora_envio) values ('2013-02-18 18:54:20', '16.928725557154415', '-89.89152860131219', '0', '0', '99', '200', 'A', '2013-02-18 18:56:53')
2013-02-18 18:54:20 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-18 18:54:20', 'End of Store in Data Base')
2013-02-18 18:54:20 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-18 18:54:20', 'End of LocationChanged')
** Service (gps) Destroy **
2013-02-18 18:54:20 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-18 18:54:20', 'Service Destroy')
** Activity (main) Create, isFirst = true **
FistTime is executed
Rutinas.Open_DataBase -- Database is Open
2013-02-18 18:55:14 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Main.Create.FirstTime','2013-02-18 18:55:14', 'DataBase Opened')
** Activity (main) Resume **
** Service (gps) Create **
2013-02-18 18:55:14 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-18 18:55:14', 'Service_Create')
** Service (gps) Start **
2013-02-18 18:55:14 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-18 18:55:14', 'Service_Start')
2013-02-18 18:55:14 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-18 18:55:14', 'Stop previos GPS')
2013-02-18 18:55:14 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-18 18:55:14', 'Next Schedule : 2013-02-18 18:58:14')
2013-02-18 18:55:15 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-18 18:55:15', 'GPS Start')
2013-02-18 18:55:15 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-18 18:55:15', 'Start without filters')
2013-02-18 18:55:19 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Main.Exit','2013-02-18 18:55:19', 'Trying to exit')
2013-02-18 18:55:21 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Main.Exit','2013-02-18 18:55:21', 'User respond YES to exit')
2013-02-18 18:55:21 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Main.Exit','2013-02-18 18:55:21', 'Current Hour :18')
2013-02-18 18:55:21 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Main.Exit','2013-02-18 18:55:21', 'SysGPSBeginHour :8')
2013-02-18 18:55:21 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Main.Exit','2013-02-18 18:55:21', 'SysGPSEndHour :22')
2013-02-18 18:55:21 Before of write in the database: INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Main.Exit','2013-02-18 18:55:21', 'Exit Aplication')
Main.Exit - Exit Aplication
** Service (gps) Destroy **
INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Service.GPS','2013-02-18 18:55:21', 'Service Destroy')
Rutinas.Write_Log --- Database is NOT open
** Activity (main) Pause, UserClosed = true **
INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Main.Exit','2013-02-18 18:55:21', 'Trying to exit')
Rutinas.Write_Log --- Database is NOT open
INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Main.Exit','2013-02-18 18:55:21', 'User say NO to exit')
Rutinas.Write_Log --- Database is NOT open
** Activity (main) Create, isFirst = false **
** Activity (main) Resume **
INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Main.Exit','2013-02-18 18:55:22', 'Trying to exit')
Rutinas.Write_Log --- Database is NOT open
INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Main.Exit','2013-02-18 18:55:23', 'User respond YES to exit')
Rutinas.Write_Log --- Database is NOT open
INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Main.Exit','2013-02-18 18:55:23', 'Current Hour :18')
Rutinas.Write_Log --- Database is NOT open
INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Main.Exit','2013-02-18 18:55:23', 'SysGPSBeginHour :8')
Rutinas.Write_Log --- Database is NOT open
INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Main.Exit','2013-02-18 18:55:23', 'SysGPSEndHour :22')
Rutinas.Write_Log --- Database is NOT open
INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Main.Exit','2013-02-18 18:55:23', 'Exit Aplication')
Rutinas.Write_Log --- Database is NOT open
Main.Exit - Exit Aplication
** Activity (main) Pause, UserClosed = true **
INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Main.Exit','2013-02-18 18:55:23', 'Trying to exit')
Rutinas.Write_Log --- Database is NOT open
INSERT INTO sg_t_log (programa, fecha_hora, info) values ('Main.Exit','2013-02-18 18:55:23', 'User say NO to exit')
Rutinas.Write_Log --- Database is NOT open

Any Help is WELCOME
 
Upvote 0

abner69

Member
Licensed User
Longtime User
Your fix

Edgar,

here is your fix. I move your globals from main to the service, and mod your database handling ... if you have any questions, ask.


...Pablo
 

Attachments

  • gps.zip
    12.3 KB · Views: 144
Upvote 0

abner69

Member
Licensed User
Longtime User
I did this based on your code looking like you wish to update your databases from within the service.

by moving the globals to your Service, you will not loose in case the activity is closed. now the activity, your code module, and the service all have access...

you will now also notice that the activity does not continuously keep firing also..


me entiendes?

...Pablo
 
Upvote 0

edgar_ortiz

Active Member
Licensed User
Longtime User
Again thanks for your time.

Yes I understand... but according to:
http://www.b4x.com/forum/basic4andr...87-android-process-activities-life-cycle.html

HTML:
Process variables - These variables live as long as the process lives.
You should declare these variables inside sub Process_Globals.
This sub is called once when the process starts (this is true for all activities, not just the first activity).
These variables are the only "public" variables. Which means that they can be accessed from other modules as well.

Then... are "public" or only sometimes??

I'm working with your code... thanks again.

P.D.:
I send you a private message
 
Upvote 0
Top