Enable WiFi While Checking Location
Refs #167 Signed-off-by: Ricky Barrette <rickbarrette@gmail.com>
This commit is contained in:
@@ -2,8 +2,8 @@
|
|||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="org.RickBarrette.android.LocationRinger"
|
package="org.RickBarrette.android.LocationRinger"
|
||||||
android:installLocation="internalOnly"
|
android:installLocation="internalOnly"
|
||||||
android:versionCode="221"
|
android:versionCode="236"
|
||||||
android:versionName="1.1" >
|
android:versionName="ff72f9d" >
|
||||||
|
|
||||||
<uses-sdk android:minSdkVersion="8" />
|
<uses-sdk android:minSdkVersion="8" />
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,9 @@ import android.content.ComponentName;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
import android.net.ConnectivityManager;
|
||||||
|
import android.net.NetworkInfo;
|
||||||
|
import android.net.wifi.WifiManager;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
import anroid.v4.compat.NotificationCompat;
|
import anroid.v4.compat.NotificationCompat;
|
||||||
|
|
||||||
@@ -72,11 +75,11 @@ public class LocationService extends com.TwentyCodes.android.location.LocationSe
|
|||||||
|
|
||||||
private NotificationManager mNotificationManager;
|
private NotificationManager mNotificationManager;
|
||||||
|
|
||||||
|
private WifiManager mWifiManager;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
*
|
*
|
||||||
* @see com.TwentyCodes.android.SkyHook.SkyHookService#onCreate()
|
|
||||||
*
|
|
||||||
* @author ricky barrette
|
* @author ricky barrette
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@@ -85,20 +88,35 @@ public class LocationService extends com.TwentyCodes.android.location.LocationSe
|
|||||||
mSettings = getSharedPreferences(SettingsActivity.SETTINGS, Constraints.SHARED_PREFS_MODE);
|
mSettings = getSharedPreferences(SettingsActivity.SETTINGS, Constraints.SHARED_PREFS_MODE);
|
||||||
mSettings.edit().putBoolean(SettingsActivity.IS_SERVICE_STARTED, true).commit();
|
mSettings.edit().putBoolean(SettingsActivity.IS_SERVICE_STARTED, true).commit();
|
||||||
startOnGoingNotification();
|
startOnGoingNotification();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* enable wifi to aid in finding location.
|
||||||
|
* This will allow for faster location fixes
|
||||||
|
*/
|
||||||
|
mWifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
|
||||||
|
mWifiManager.setWifiEnabled(true);
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
*
|
*
|
||||||
* @see com.TwentyCodes.android.SkyHook.SkyHookService#onDestroy()
|
|
||||||
*
|
|
||||||
* @author ricky barrette
|
* @author ricky barrette
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
mSettings.edit().remove(SettingsActivity.IS_SERVICE_STARTED).commit();
|
mSettings.edit().remove(SettingsActivity.IS_SERVICE_STARTED).commit();
|
||||||
mNotificationManager.cancel(GATHERING_LOCATION_ONGING_NOTIFICATION_ID);
|
mNotificationManager.cancel(GATHERING_LOCATION_ONGING_NOTIFICATION_ID);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* disable wifi IF NOT connected to a network
|
||||||
|
*/
|
||||||
|
ConnectivityManager connManager = (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE);
|
||||||
|
NetworkInfo wifiNetInfo = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
|
||||||
|
|
||||||
|
if (! wifiNetInfo.isConnected())
|
||||||
|
mWifiManager.setWifiEnabled(false);
|
||||||
|
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user