Search code examples
androidandroid-wifiandroid-locationgoogle-awareness

android disable wifi when user leaves home


I've searched all around for something that will do a simple action : disable wifi when user leaves home, and enable wifi when arriving home.
I want to do so, since it could potentially save me battery usage from searching wifi network when i'm outside.

Here's what i thought about :

  1. For enabling and disabling wifi, i can use this suggestion.
  2. For detecting home, i can use FenceApi and set a specific coordinate for this. Something like :

    AwarenessFence fence = LocationFence.entering(55.683491, 12.101225, 25);
    Awareness.FenceApi.updateFences(mGoogleApiClient, new FenceUpdateRequest.Builder...);
    

This is done with the FenceApi, which overall works fine, but sometimes its missing notifying enter the coordinates i've specified.

The issue is, i don't want to implement my own home, since i don't have a server side implementation for my application, and it'll be very hard to save all of the home data of my users. Just wandering if anyone know of any open source sdk which can be useful for my usage.


Solution

  • You can use this open source git project, which uses Neura sdk(which is free).

    Bassically, this is exactly what you need, since it detects leaving and arriving home.

    1. When user left home, the wifi is disabled.
    2. When user arrive to work, the wifi is enabled.