|
@@ -9,12 +9,14 @@ import java.util.Map;
|
|
|
|
|
|
import android.app.Activity;
|
|
import android.app.Activity;
|
|
import android.app.AlertDialog;
|
|
import android.app.AlertDialog;
|
|
-import android.app.Fragment;
|
|
|
|
import android.app.FragmentManager;
|
|
import android.app.FragmentManager;
|
|
|
|
+import android.content.Context;
|
|
import android.content.DialogInterface;
|
|
import android.content.DialogInterface;
|
|
-import android.content.SharedPreferences;
|
|
|
|
import android.graphics.Color;
|
|
import android.graphics.Color;
|
|
|
|
+import android.location.Criteria;
|
|
import android.location.Location;
|
|
import android.location.Location;
|
|
|
|
+import android.location.LocationListener;
|
|
|
|
+import android.location.LocationManager;
|
|
import android.os.Bundle;
|
|
import android.os.Bundle;
|
|
import android.text.Html;
|
|
import android.text.Html;
|
|
import android.view.InflateException;
|
|
import android.view.InflateException;
|
|
@@ -25,9 +27,6 @@ import android.widget.TextView;
|
|
|
|
|
|
import com.google.android.gms.common.ConnectionResult;
|
|
import com.google.android.gms.common.ConnectionResult;
|
|
import com.google.android.gms.common.GooglePlayServicesClient;
|
|
import com.google.android.gms.common.GooglePlayServicesClient;
|
|
-import com.google.android.gms.location.LocationClient;
|
|
|
|
-import com.google.android.gms.location.LocationListener;
|
|
|
|
-import com.google.android.gms.location.LocationRequest;
|
|
|
|
import com.google.android.gms.maps.CameraUpdateFactory;
|
|
import com.google.android.gms.maps.CameraUpdateFactory;
|
|
import com.google.android.gms.maps.GoogleMap;
|
|
import com.google.android.gms.maps.GoogleMap;
|
|
import com.google.android.gms.maps.MapFragment;
|
|
import com.google.android.gms.maps.MapFragment;
|
|
@@ -63,13 +62,9 @@ public class ThreatMapFragment extends TrackerFragment implements GoogleMap.OnIn
|
|
|
|
|
|
private static HashMap<String, String> sMarkerIDToSSID = new HashMap<String, String>();
|
|
private static HashMap<String, String> sMarkerIDToSSID = new HashMap<String, String>();
|
|
|
|
|
|
- private LocationClient mLocationClient;
|
|
+ private LocationManager mLocationManager;
|
|
-
|
|
+
|
|
- private static final LocationRequest REQUEST = LocationRequest.create()
|
|
+ private String mLocationProvider;
|
|
- .setExpirationDuration(5000)
|
|
|
|
- .setInterval(5000)
|
|
|
|
- .setFastestInterval(16)
|
|
|
|
- .setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
|
|
|
|
|
|
|
|
|
|
|
|
* if google play services aren't available an error notification will be displayed
|
|
* if google play services aren't available an error notification will be displayed
|
|
@@ -119,17 +114,14 @@ public class ThreatMapFragment extends TrackerFragment implements GoogleMap.OnIn
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public void onConnected(Bundle bundle) {
|
|
public void onConnected(Bundle bundle) {
|
|
- mLocationClient.requestLocationUpdates(REQUEST, this);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void onDisconnected() {
|
|
public void onDisconnected() {
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void onConnectionFailed(ConnectionResult connectionResult) {
|
|
public void onConnectionFailed(ConnectionResult connectionResult) {
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -138,6 +130,18 @@ public class ThreatMapFragment extends TrackerFragment implements GoogleMap.OnIn
|
|
new LatLng(location.getLatitude(), location.getLongitude())));
|
|
new LatLng(location.getLatitude(), location.getLongitude())));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public void onStatusChanged(String provider, int status, Bundle extras) {
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void onProviderEnabled(String provider) {
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void onProviderDisabled(String provider) {
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
* helper class
|
|
* helper class
|
|
* easier to use than LatLng
|
|
* easier to use than LatLng
|
|
@@ -395,6 +399,12 @@ public class ThreatMapFragment extends TrackerFragment implements GoogleMap.OnIn
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
|
|
+ mLocationManager = (LocationManager)activity.getSystemService(Context.LOCATION_SERVICE);
|
|
|
|
+ Criteria criteria = new Criteria();
|
|
|
|
+ criteria.setAccuracy(Criteria.ACCURACY_FINE);
|
|
|
|
+ mLocationProvider = mLocationManager.getBestProvider(criteria, false);
|
|
|
|
+ mLocationManager.requestLocationUpdates(mLocationProvider, (long)0, 1000.0f, (LocationListener)this);
|
|
|
|
+
|
|
sMap.setMyLocationEnabled(true);
|
|
sMap.setMyLocationEnabled(true);
|
|
|
|
|
|
LatLng tudarmstadt = new LatLng(49.86923, 8.6632768);
|
|
LatLng tudarmstadt = new LatLng(49.86923, 8.6632768);
|
|
@@ -424,18 +434,12 @@ public class ThreatMapFragment extends TrackerFragment implements GoogleMap.OnIn
|
|
@Override
|
|
@Override
|
|
public void onResume() {
|
|
public void onResume() {
|
|
super.onResume();
|
|
super.onResume();
|
|
- if (mLocationClient == null) {
|
|
+ mLocationManager.requestLocationUpdates(mLocationProvider, 0, 1000.0f, this);
|
|
- mLocationClient = new LocationClient(MainActivity.getInstance().getApplicationContext(),
|
|
|
|
- this, this);
|
|
|
|
- }
|
|
|
|
- mLocationClient.connect();
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void onPause() {
|
|
public void onPause() {
|
|
super.onPause();
|
|
super.onPause();
|
|
- if (mLocationClient != null) {
|
|
+ mLocationManager.removeUpdates(this);
|
|
- mLocationClient.disconnect();
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|