瀏覽代碼

1.添加百度地图定位。

20241218TB223FC(测试jar包)
wangwanlei 8 月之前
父節點
當前提交
2b4a1e470b

+ 4
- 0
app/build.gradle.kts 查看文件

@@ -24,6 +24,9 @@ android {
24 24
         vectorDrawables {
25 25
             useSupportLibrary = true
26 26
         }
27
+        ndk{
28
+            abiFilters += listOf("armeabi","armeabi-v7a","arm64-v8a","x86","x86_64")
29
+        }
27 30
     }
28 31
     viewBinding{
29 32
         enable=true
@@ -118,6 +121,7 @@ dependencies {
118 121
     implementation(project(mapOf("path" to ":websocket")))
119 122
     implementation(libs.androidx.cardview)
120 123
     testImplementation(libs.junit)
124
+    implementation("com.baidu.lbsyun:BaiduMapSDK_Location_All:9.3.7")
121 125
     androidTestImplementation(libs.androidx.test.ext.junit)
122 126
     androidTestImplementation(libs.espresso.core)
123 127
     androidTestImplementation(platform(libs.compose.bom))

二進制
app/libs/arm64-v8a/libindoor.so 查看文件


二進制
app/libs/arm64-v8a/liblocSDK8b.so 查看文件


二進制
app/libs/armeabi-v7a/libindoor.so 查看文件


二進制
app/libs/armeabi-v7a/liblocSDK8b.so 查看文件


+ 5
- 0
app/src/main/AndroidManifest.xml 查看文件

@@ -59,6 +59,11 @@
59 59
         <meta-data
60 60
             android:name="design_height_in_dp"
61 61
             android:value="667" /> <!-- 全局内容提供者 -->
62
+        <meta-data
63
+            android:name="com.baidu.lbsapi.API_KEY"
64
+            android:value="9eZF1Cg9JYIzme7dSnG8rmeUj7ET3lK1" >
65
+        </meta-data>
66
+        <service android:name="com.baidu.location.f" android:enabled="true" android:process=":remote"> </service>
62 67
         <activity
63 68
             android:name="com.xhly.manageapp.ui.main.activity.MainActivity"
64 69
             android:exported="true"

+ 9
- 0
app/src/main/java/com/xhly/manageapp/bean/PadLocationConst.kt 查看文件

@@ -0,0 +1,9 @@
1
+package com.xhly.manageapp.bean
2
+
3
+import com.xhly.manageapp.bean.log.PadLocationBean
4
+
5
+//存储地理位置,用来上传数据
6
+object PadLocationConst {
7
+    val currentLocation=PadLocationBean()
8
+    val lastLocation=PadLocationBean()
9
+}

+ 7
- 2
app/src/main/java/com/xhly/manageapp/bean/log/PadLocationBean.kt 查看文件

@@ -7,12 +7,12 @@ class PadLocationBean {
7 7
     /**
8 8
      * 经度
9 9
      */
10
-    var lon:Double = 0.0
10
+    var lon:Double? = null
11 11
 
12 12
     /**
13 13
      * 维度
14 14
      */
15
-    var lat:Double = 0.0
15
+    var lat:Double? =null
16 16
 
17 17
     /**
18 18
      * 用户id
@@ -23,4 +23,9 @@ class PadLocationBean {
23 23
      * 设备sn
24 24
      */
25 25
     var sn = ""
26
+
27
+    /**
28
+     * address
29
+     */
30
+    var address:String?=null
26 31
 }

+ 11
- 0
app/src/main/java/com/xhly/manageapp/ui/main/viewmodel/MainViewModel.kt 查看文件

@@ -12,6 +12,7 @@ import com.xhly.manageapp.bean.log.UpdateBean
12 12
 import com.xhly.manageapp.bean.WallpaperBean
13 13
 import com.xhly.manageapp.bean.app.AppInstallBean
14 14
 import com.xhly.manageapp.bean.log.PadInfoBean
15
+import com.xhly.manageapp.bean.log.PadLocationBean
15 16
 import com.xhly.manageapp.bean.school.SchoolDeviceSetBean
16 17
 import com.xhly.manageapp.bean.strategy.AppTimeManageBean
17 18
 import com.xhly.manageapp.bean.strategy.StrategyBean
@@ -250,4 +251,14 @@ class MainViewModel : BaseViewModel() {
250 251
             }
251 252
         }
252 253
     }
254
+
255
+    /**
256
+     * 发送定位
257
+     */
258
+
259
+    fun  postPadLocation(location:PadLocationBean){
260
+        launchUI {
261
+            logService.postPadLocation(location)
262
+        }
263
+    }
253 264
 }

+ 11
- 8
app/src/main/java/com/xhly/manageapp/workmanager/TimingWorker.kt 查看文件

@@ -15,6 +15,7 @@ import com.xhly.corelib.utils.SharedPreferencesUtils
15 15
 import com.xhly.corelib.utils.SystemUtil
16 16
 import com.xhly.corelib.utils.toFormat
17 17
 import com.xhly.manageapp.ManageApplication
18
+import com.xhly.manageapp.bean.PadLocationConst
18 19
 import com.xhly.manageapp.bean.log.LogAppStartBean
19 20
 import com.xhly.manageapp.bean.log.PadLocationBean
20 21
 import com.xhly.manageapp.bean.user.UserBean
@@ -59,19 +60,20 @@ class TimingWorker(context: Context, workerParams: WorkerParameters) :
59 60
             if (appInfo.size > 0) {
60 61
                 logService.postLogAppStartAdd(appInfo)
61 62
             }
63
+/*
62 64
             try {
63
-                val location = SystemUtil.getLocation(applicationContext)
64
-                if (location!=null){
65
-                    val padLocationBean=PadLocationBean()
66
-                    padLocationBean.lat=location.latitude
67
-                    padLocationBean.lon=location.longitude
65
+                val location = PadLocationConst.currentLocation
66
+                val lastLocation = PadLocationConst.lastLocation
67
+                if (location.lat!=null&&location.lon!=null&&(lastLocation.lon!=location.lon&&lastLocation.lat!=location.lat)){
68
+                    lastLocation.lat=location.lat
69
+                    lastLocation.lon=location.lon
68 70
                     ManageApplication.getDeviceInfo()?.let {
69
-                        padLocationBean.sn=it
71
+                        location.sn=it
70 72
                     }
71 73
                     userBean?.let {
72
-                        padLocationBean.userid=it.userid
74
+                        location.userid=it.userid
73 75
                     }
74
-                    logService.postPadLocation(padLocationBean)
76
+                    logService.postPadLocation(location)
75 77
                     LogShow("真没有位置")
76 78
                 }else{
77 79
                     LogShow("没有位置")
@@ -79,6 +81,7 @@ class TimingWorker(context: Context, workerParams: WorkerParameters) :
79 81
             }catch (e:Exception){
80 82
                 LogShow("没有位置问题"+e.toString())
81 83
             }
84
+*/
82 85
             //创建socket
83 86
             userBean?.let {
84 87
                 ManageApplication.instance?.let {

Loading…
取消
儲存