Commit 88db9469 by 罗翻

更改locationUtils

parent aa59c105
package com.dayu.location.base;
import android.annotation.SuppressLint;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
......@@ -20,12 +21,11 @@ import java.io.File;
*/
public class LocationUtils {
@SuppressLint("StaticFieldLeak")
private static AMapLocationClient mlocationClient;
private static AMapLocation sLocation = null;
private static boolean flag = true;
private static MyLocationListener mListener;
private static Handler mHandler;
private static OpenMarketListener marketListener;
/**
* @param context
......@@ -75,8 +75,7 @@ public class LocationUtils {
* @Title: getCurrentLocation
* @Description: 获取位置,重新发起获取位置请求
*/
public static void getCurrentLocation(MyLocationListener listener) {
mListener = listener;
public static void getCurrentLocation(final MyLocationListener listener) {
if (mlocationClient == null) {
return;
}
......@@ -87,7 +86,7 @@ public class LocationUtils {
@Override
public void run() {
if (flag) {
mListener.result(sLocation);
listener.result(sLocation);
flag = false;
mlocationClient.stopLocation();
}
......@@ -102,7 +101,7 @@ public class LocationUtils {
flag = false;
mlocationClient.stopLocation();
sLocation = location;
mListener.result(location);
listener.result(location);
mHandler = null;
}
}
......@@ -120,7 +119,6 @@ public class LocationUtils {
if (mlocationClient != null) {
mlocationClient.onDestroy();
}
mListener = null;
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment