增加初始化功能

This commit is contained in:
2025-09-11 16:09:07 +08:00
parent e153f3e3b9
commit a355828bab
21 changed files with 1286 additions and 57 deletions
@@ -1,8 +1,10 @@
package com.shuwei.intelligent.shelves
import android.app.Application
import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import android.content.SharedPreferences
import com.shuwei.intelligent.shelves.utils.BootReceiver
/**
@@ -10,14 +12,8 @@ import com.shuwei.intelligent.shelves.utils.BootReceiver
* @date: 2022-04-26
*/
class App : Application() {
//从接口获取
var accessToken: String = ""
//"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJjYW50ZWVuSWQiOiIiLCJ0eXBlIjoiNiIsInVzZXJJZCI6IjE2NzgyMjY1NTI5MzE1NDkxODYifQ.CQmbELpqT6QzvVCgCeirwvSvPp8Mhft_h6b1Af574Co"
var deviceId:String = ""
var canteenId:String = ""
override fun onCreate() {
super.onCreate()
app = this
@@ -27,9 +23,26 @@ class App : Application() {
companion object {
private lateinit var app: App
var canteenId = "0"
var appVersion = "1"
var configUrl = ""
//从接口获取
var accessToken: String = ""
var deviceId: String = ""
@Volatile
private var sharedPref: SharedPreferences? = null
fun getInstance(): App {
return app
}
fun getSharedPref(): SharedPreferences? {
if (sharedPref != null) {
return sharedPref
}
sharedPref = app.getSharedPreferences("sp_intelligent_shelves", Context.MODE_PRIVATE)
return sharedPref
}
}
}