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 /** * @author: star * @date: 2022-04-26 */ class App : Application() { //"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJjYW50ZWVuSWQiOiIiLCJ0eXBlIjoiNiIsInVzZXJJZCI6IjE2NzgyMjY1NTI5MzE1NDkxODYifQ.CQmbELpqT6QzvVCgCeirwvSvPp8Mhft_h6b1Af574Co" override fun onCreate() { super.onCreate() app = this val filter = IntentFilter(Intent.ACTION_BOOT_COMPLETED) registerReceiver(BootReceiver(), filter) } 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 } } }