Commit 03101890eaa3f39db3344426eed0d467d3493f37
1 parent
5ff829c6
兼容4.4版本定位问题
Showing
3 changed files
with
28 additions
and
13 deletions
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/utils/CheckUtil.java
| ... | ... | @@ -29,11 +29,12 @@ public class CheckUtil { |
| 29 | 29 | if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) { |
| 30 | 30 | boolean hasIgnored = powerManager.isIgnoringBatteryOptimizations(context.getPackageName()); |
| 31 | 31 | return hasIgnored; |
| 32 | + } else { | |
| 33 | + return true; | |
| 32 | 34 | } |
| 33 | 35 | } else { |
| 34 | 36 | return true; |
| 35 | 37 | } |
| 36 | - return false; | |
| 37 | 38 | } catch (Exception e) { |
| 38 | 39 | return true; |
| 39 | 40 | } | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/utils/MyMapUtil.java
| ... | ... | @@ -594,20 +594,25 @@ public class MyMapUtil { |
| 594 | 594 | */ |
| 595 | 595 | public static final boolean isOPenGps(final Context context) { |
| 596 | 596 | try { |
| 597 | - LocationManager locationManager | |
| 598 | - = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); | |
| 599 | - // 通过GPS卫星定位,定位级别可以精确到街(通过24颗卫星定位,在室外和空旷的地方定位准确、速度快) | |
| 600 | - boolean gps = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER); | |
| 601 | - // 通过WLAN或移动网络(3G/2G)确定的位置(也称作AGPS,辅助GPS定位。主要用于在室内或遮盖物(建筑群或茂密的深林等)密集的地方定位) | |
| 602 | - boolean network = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER); | |
| 603 | - if (gps) { | |
| 597 | + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) { | |
| 598 | + LocationManager locationManager | |
| 599 | + = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); | |
| 600 | + // 通过GPS卫星定位,定位级别可以精确到街(通过24颗卫星定位,在室外和空旷的地方定位准确、速度快) | |
| 601 | + boolean gps = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER); | |
| 602 | + // 通过WLAN或移动网络(3G/2G)确定的位置(也称作AGPS,辅助GPS定位。主要用于在室内或遮盖物(建筑群或茂密的深林等)密集的地方定位) | |
| 603 | + boolean network = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER); | |
| 604 | + if (gps) { | |
| 605 | + return true; | |
| 606 | + } else { | |
| 607 | + return false; | |
| 608 | + } | |
| 609 | + } else { | |
| 604 | 610 | return true; |
| 605 | 611 | } |
| 606 | 612 | } catch (Exception e) { |
| 607 | 613 | //异常就返回true |
| 608 | 614 | return true; |
| 609 | 615 | } |
| 610 | - return false; | |
| 611 | 616 | } |
| 612 | 617 | |
| 613 | 618 | /** | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/utils/NotificationUtil.java
| ... | ... | @@ -17,10 +17,19 @@ public class NotificationUtil { |
| 17 | 17 | private static NotificationManagerCompat notificationManagerCompat; |
| 18 | 18 | |
| 19 | 19 | public static boolean isOpenNotification(Activity activity) { |
| 20 | - //监测通知权限是否打开 | |
| 21 | - notificationManagerCompat = NotificationManagerCompat.from(activity); | |
| 22 | - isOpen = notificationManagerCompat.areNotificationsEnabled(); | |
| 23 | - return isOpen; | |
| 20 | + try { | |
| 21 | + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) { | |
| 22 | + //监测通知权限是否打开 | |
| 23 | + notificationManagerCompat = NotificationManagerCompat.from(activity); | |
| 24 | + isOpen = notificationManagerCompat.areNotificationsEnabled(); | |
| 25 | + return isOpen; | |
| 26 | + } else { | |
| 27 | + return true; | |
| 28 | + } | |
| 29 | + } catch (Exception e) { | |
| 30 | + return true; | |
| 31 | + } | |
| 32 | + | |
| 24 | 33 | } |
| 25 | 34 | |
| 26 | 35 | public static void goToSettingNo(Activity activity) { | ... | ... |