From 159dcb5c3b04a268c20c131df4ab99c1ae12e7db Mon Sep 17 00:00:00 2001
From: mac <user@users-MacBook-Pro.local>
Date: 星期五, 26 一月 2024 18:29:47 +0800
Subject: [PATCH] 2024年01月26日18:29:37

---
 app/src/main/java/com/hdl/photovoltaic/ui/MyPowerStationActivity.java |   98 +++++++++++++++++++++++++++++++++---------------
 1 files changed, 67 insertions(+), 31 deletions(-)

diff --git a/app/src/main/java/com/hdl/photovoltaic/ui/MyPowerStationActivity.java b/app/src/main/java/com/hdl/photovoltaic/ui/MyPowerStationActivity.java
index 96b822e..dfef1b7 100644
--- a/app/src/main/java/com/hdl/photovoltaic/ui/MyPowerStationActivity.java
+++ b/app/src/main/java/com/hdl/photovoltaic/ui/MyPowerStationActivity.java
@@ -2,11 +2,14 @@
 
 import androidx.annotation.NonNull;
 import androidx.appcompat.content.res.AppCompatResources;
+import androidx.core.app.ActivityCompat;
 
 import android.Manifest;
 import android.content.Context;
 import android.content.Intent;
 import android.content.pm.PackageManager;
+import android.location.Location;
+import android.location.LocationListener;
 import android.location.LocationManager;
 import android.os.Bundle;
 import android.os.Process;
@@ -94,8 +97,6 @@
         this.pushTokens();
         //鐐瑰嚮鏋佸厜閫氱煡鏍忔秷鎭繘鏉�
         this.clickJpushNotificationMessage();
-        //閫氱煡闄愭潈
-        this.notificationSet();
         //鍒濆鍖栨潈闄�
         this.requestPermissions();
 
@@ -106,7 +107,8 @@
      * 涓婁紶鏋佸厜娉ㄥ唽ID鍒颁簯绔�
      */
     private void pushTokens() {
-        String is_registrationID = HDLApp.getInstance().getKey("registrationID");
+        String registrationId_tag="registrationID_"+UserConfigManage.getInstance().getUserId();
+        String is_registrationID = HDLApp.getInstance().getKey(registrationId_tag);
         if (is_registrationID.equals("true")) {
             //涓婅繃灏辨病鏈夊繀瑕佸湪涓婁紶鍟�
             return;
@@ -138,13 +140,14 @@
                                 UserConfigManage.getInstance().setPushId(pushId);
                                 UserConfigManage.getInstance().Save();
                             }
-                            HDLApp.getInstance().setInfoMap("registrationID", "true");//璁板綍涓�涓嬬姸鎬�,鍚庡彴鏉�姝籥pp浼氭竻绌�;
+                            HDLApp.getInstance().setInfoMap(registrationId_tag, "true");//璁板綍涓�涓嬬姸鎬�,鍚庡彴鏉�姝籥pp浼氭竻绌�;
                             HdlLogLogic.print("娣诲姞鏋佸厜ID鍒颁簯绔�--->registrationID:" + finalRegistrationID, true);
 
                         }
 
                         @Override
                         public void onFailure(HDLException e) {
+                            HDLApp.getInstance().setInfoMap(registrationId_tag, "false");//璁板綍涓�涓嬬姸鎬�,鍚庡彴鏉�姝籥pp浼氭竻绌�;
                             HdlLogLogic.print("娣诲姞鏋佸厜ID鍒颁簯绔け璐�--->registrationID:" + finalRegistrationID, true);
                         }
                     });
@@ -279,6 +282,8 @@
     }
 
     public void requestPermissions() {
+        //娑堟伅閫氱煡闄愭潈
+        this.notificationSet();
         //Manifest.permission.ACCESS_COARSE_LOCATION
         //ACCESS_FINE_LOCATION	鍏佽浣跨敤GPS瀹氫綅
         //ACCESS_COARSE_LOCATION	鍏佽浣跨敤WIFI鐑偣鎴栧熀绔欐潵鑾峰彇绮楃暐鐨勫畾浣�
@@ -528,8 +533,38 @@
      * 鍒濆鍖栥�愬紑鍚畾浣嶃�戝拰銆愪綅缃俊鎭�戞潈闄�
      */
     private void locationUpdates() {
+
+
         // 鍒濆鍖朙ocationManager瀵硅薄
         LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
+//        //INTERNET	鍏佽浣跨敤缃戠粶
+//        //ACCESS_FINE_LOCATION	鍏佽浣跨敤GPS瀹氫綅
+//        //ACCESS_COARSE_LOCATION	鍏佽浣跨敤WIFI鐑偣鎴栧熀绔欐潵鑾峰彇绮楃暐鐨勫畾浣�
+//        if (ActivityCompat.checkSelfPermission(_mActivity, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
+//            // TODO: Consider calling
+//            //    ActivityCompat#requestPermissions
+//            // here to request the missing permissions, and then overriding
+//            //   public void onRequestPermissionsResult(int requestCode, String[] permissions,
+//            //                                          int[] grantResults)
+//            // to handle the case where the user grants the permission. See the documentation
+//            // for ActivityCompat#requestPermissions for more details.
+//            return;
+//        }
+//        HdlLogLogic.print("寮�濮嬬含搴︾粡搴�--->", false);
+//        Location location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
+//
+//        //寤鸿杩欎釜 minTime 涓嶅皬浜� 60000锛屽嵆 1 鍒嗛挓锛岃繖鏍蜂細鏇村姞楂樻晥鑰屼笖鐪佺數
+//        locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, new LocationListener() {
+//            @Override
+//            public void onLocationChanged(@NonNull Location location) {
+//                // 褰撲綅缃彂鐢熷彉鍖栨椂璋冪敤姝ゆ柟娉�
+//                double latitude = location.getLatitude();   // 鑾峰彇绾害
+//                double longitude = location.getLongitude(); // 鑾峰彇缁忓害
+//
+//                HdlLogLogic.print("绾害--->" + latitude, true);
+//                HdlLogLogic.print("缁忓害--->" + longitude, true);
+//            }
+//        });
         // 鍒ゆ柇璁惧鏄惁鏀寔瀹氫綅鍔熻兘
         if (!locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
             // 鎻愮ず鐢ㄦ埛鎵撳紑瀹氫綅鍔熻兘鎴栬�呭紩瀵肩敤鎴峰幓绯荤粺璁剧疆椤甸潰鎵撳紑瀹氫綅鍔熻兘
@@ -556,34 +591,35 @@
             });
 
         } else {
-//            //INTERNET	鍏佽浣跨敤缃戠粶
-//            //ACCESS_FINE_LOCATION	鍏佽浣跨敤GPS瀹氫綅
-//            //ACCESS_COARSE_LOCATION	鍏佽浣跨敤WIFI鐑偣鎴栧熀绔欐潵鑾峰彇绮楃暐鐨勫畾浣�
-//            if (ActivityCompat.checkSelfPermission(_mActivity, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
-//                // TODO: Consider calling
-//                //    ActivityCompat#requestPermissions
-//                // here to request the missing permissions, and then overriding
-//                //   public void onRequestPermissionsResult(int requestCode, String[] permissions,
-//                //                                          int[] grantResults)
-//                // to handle the case where the user grants the permission. See the documentation
-//                // for ActivityCompat#requestPermissions for more details.
-//                return;
-//            }
-//            HdlLogLogic.print("寮�濮嬬含搴︾粡搴�--->", true);
+            //INTERNET	鍏佽浣跨敤缃戠粶
+            //ACCESS_FINE_LOCATION	鍏佽浣跨敤GPS瀹氫綅
+            //ACCESS_COARSE_LOCATION	鍏佽浣跨敤WIFI鐑偣鎴栧熀绔欐潵鑾峰彇绮楃暐鐨勫畾浣�
+            if (ActivityCompat.checkSelfPermission(_mActivity, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
+                // TODO: Consider calling
+                //    ActivityCompat#requestPermissions
+                // here to request the missing permissions, and then overriding
+                //   public void onRequestPermissionsResult(int requestCode, String[] permissions,
+                //                                          int[] grantResults)
+                // to handle the case where the user grants the permission. See the documentation
+                // for ActivityCompat#requestPermissions for more details.
+                return;
+            }
+            HdlLogLogic.print("寮�濮嬬含搴︾粡搴�--->", false);
 //            Location location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
-//
-//            //寤鸿杩欎釜 minTime 涓嶅皬浜� 60000锛屽嵆 1 鍒嗛挓锛岃繖鏍蜂細鏇村姞楂樻晥鑰屼笖鐪佺數
-//            locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, new LocationListener() {
-//                @Override
-//                public void onLocationChanged(@NonNull Location location) {
-//                    // 褰撲綅缃彂鐢熷彉鍖栨椂璋冪敤姝ゆ柟娉�
-//                    double latitude = location.getLatitude();   // 鑾峰彇绾害
-//                    double longitude = location.getLongitude(); // 鑾峰彇缁忓害
-//
-//                    HdlLogLogic.print("绾害--->" + latitude, true);
-//                    HdlLogLogic.print("缁忓害--->" + longitude, true);
-//                }
-//            });
+
+            //寤鸿杩欎釜 minTime 涓嶅皬浜� 60000锛屽嵆 1 鍒嗛挓锛岃繖鏍蜂細鏇村姞楂樻晥鑰屼笖鐪佺數
+            locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 60 * 1000, 10, new LocationListener() {
+                @Override
+                public void onLocationChanged(@NonNull Location location) {
+                    // 褰撲綅缃彂鐢熷彉鍖栨椂璋冪敤姝ゆ柟娉�
+                    double latitude = location.getLatitude();   // 鑾峰彇绾害
+                    double longitude = location.getLongitude(); // 鑾峰彇缁忓害
+
+
+                    HdlLogLogic.print("绾害--->" + latitude, false);
+                    HdlLogLogic.print("缁忓害--->" + longitude, false);
+                }
+            });
         }
 
 

--
Gitblit v1.8.0