@@ -116,6 +116,14 @@ public class Preferences {
|
||
| 116 | 116 |
return mPrefs.getBoolean("isGuestLogin",false);
|
| 117 | 117 |
} |
| 118 | 118 |
|
| 119 |
+ public boolean isPermissionGranted(){
|
|
| 120 |
+ return mPrefs.getBoolean("isPermissionGranted",true);
|
|
| 121 |
+ } |
|
| 122 |
+ |
|
| 123 |
+ public void setPermissionGranted(boolean isPermissionGranted){
|
|
| 124 |
+ mPrefs.edit().putBoolean("isPermissionGranted",isPermissionGranted).commit();
|
|
| 125 |
+ } |
|
| 126 |
+ |
|
| 119 | 127 |
public void clearPrefs(){
|
| 120 | 128 |
mPrefs.edit().clear().commit(); |
| 121 | 129 |
} |
@@ -194,8 +194,8 @@ public class TabRecentPhotoFragment extends BaseFragment implements SwipeRefresh |
||
| 194 | 194 |
} |
| 195 | 195 |
|
| 196 | 196 |
private void checkLocationPermission(){
|
| 197 |
- if (ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.ACCESS_FINE_LOCATION) |
|
| 198 |
- != PackageManager.PERMISSION_GRANTED) {
|
|
| 197 |
+ if (ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED |
|
| 198 |
+ ||!Preferences.getInstance(getActivity()).isPermissionGranted()) {
|
|
| 199 | 199 |
ActivityCompat.requestPermissions(getActivity(), new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
|
| 200 | 200 |
2001); |
| 201 | 201 |
} |
@@ -192,6 +192,9 @@ public class MyLocationService extends Service implements Handler.Callback{
|
||
| 192 | 192 |
AMapLocationListener locationListener = new AMapLocationListener() {
|
| 193 | 193 |
@Override |
| 194 | 194 |
public void onLocationChanged(AMapLocation loc) {
|
| 195 |
+ if(loc.getErrorCode()==AMapLocation.ERROR_CODE_FAILURE_LOCATION_PERMISSION){
|
|
| 196 |
+ Preferences.getInstance(getApplicationContext()).setPermissionGranted(false); |
|
| 197 |
+ } |
|
| 195 | 198 |
double lat = loc.getLatitude(); |
| 196 | 199 |
double lon = loc.getLongitude(); |
| 197 | 200 |
LogHelper.dfile("czy","经纬度 lat = "+lat+"lon="+lon+" 位置 ="+loc.getAddress());
|