Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: Network Radio off before ACTION_SHUTDOWN event.Events order Changed in ICS

I was sending logout to my server when user did a power off on the device.The order of events in 2.3 and 4.0.3 are as follows.So now Log out is Failed.
Device : Samsung Galaxy s2


Android : 2.3


1)Receive ACTION_SHUTDOWN
2) Send Logout event,sleep for 5 secs,LOG OUT SENT SUCCESSFULLY
3)Data Network Radio off event.
4)Device Power off.


Android : 4.0.3


1) Data Network Radio off event.
2)Receive ACTION_SHUTDOWN
3) Send Logout event,LOG OUT FAIL As Network is down.
Any way around to get ACTION_SHUTDOWN before Data Network Radio off?

like image 993
NitZRobotKoder Avatar asked Jul 17 '12 06:07

NitZRobotKoder


1 Answers

It doesn't look like vanilla Android behavior. May be your device's manufacturer did some internal improvements to the shutdown process to speed it up.

You can see how shutdown is handled at frameworks/base/services/java/com/android/server/pm/ShutdownThread.java#L296 on current master branch.

However as a mobile application developer you shouldn't rely on constant network connection.

like image 157
auselen Avatar answered Oct 20 '22 11:10

auselen