not a real dev, need help with an app to exit to home screen (or exit another application) on wifi disconnect. [closed]
Disclaimer: I h开发者_StackOverflow社区aven't done coding or dev work in a very long time, and never on android.
Running in background mode, my app needs to detect when a particular wifi signal gets lost, and then it needs to return the user to the home screen. Bonus if I can get it to kill a specific application/process as the same time.
Is this possible? If so, any tips or help building it in next 24 hours? Working on rooted motorola xoom, android 3.2.
Thus far I can tell tracking network state via either SUPPLICANT_CONNECTION_CHANGE_ACTION or NetworkInfo.DetailedState DISCONNECTING/DISCONNECTED should be viable options for monitoring the network status. What I haven't been able to yet find is how to get the app (without user action) to then return to home screen and/or exit the currently in use application... I am going to try and build this out tonight. Any help is greatly appreciated!
Use the KISS principle. It's rooted, so install Busybox or create a very simple script with the available tools which can be invoked from init.rc
, something along these lines:
while :
do
if ping -c 1 www.google.com
then
# there's connectivity, do whatever you want
:
else
# no connectivity
# kill the app
kill the-app-i-want-to-kill
# return home
am start -a android.intent.action.MAIN -c android.intent.category.HOME
fi
sleep 30
done
Ahhh, and use the other 15h 45m to find somebody that could do this app correctly.
精彩评论