Hello,
I'm writing an ordering app for android. This app is communicating via TCP/IP with a server PC. There are more than one android devices with my app connected to the server PC. (Normally each waiter will have a device for his own.) If a waiter wants to take an order for a guest sitting at table number 5 the app sends the command OpenTable/5 to the server PC. If the table 5 is available the server pc send the content of the table (the meals and drinks the guest already had) to the app and blocks this table temporarly to all other clients. (So no other waiter can pay the table while an order is taken.) The waiter can now input new orders for this table. If the waiter has finished ordering. He should press the send key ... The app sends all orders with an closetablecommand to the server. The server now commits all ordered articles and releases the lock and all other handheld devices can now access table 5 again.
This works very well but i have now a simple problem.
The waiter opens a table. The server sends the table conntent to my app and the table is locked for all other devices. Now the waiter takes the orders but instead of closing the table he powers off his device ...
So the orders are not commited and the table is still locked for all other devices ...
Is there a way to detect that the device is about to power off? I need to send the close table command to the server pc and return to the main activity of my app before falling a sleep.
Maybe someone else has a similiar problem. I simple want to finish work before the device is turned off.
I will be happy about any answer.