MyApplication.kt
1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package com.huaheng.wmspda
import android.app.Activity
import android.app.Application
import android.content.Context
import com.huaheng.wmspda.activity.ActivityCollector
import com.huaheng.wmspda.activity.BaseActivity
import com.huaheng.wmspda.bean.resp.Warehouse
import com.huaheng.wmspda.util.CrashHandler
import com.huaheng.wmspda.util.WmsSpf
class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
context = applicationContext
init()
}
/**
* 初始化设置
*/
fun init() {
//语音
// SoundUtils.getInstance(this);
//奔溃日志
CrashHandler.instance.init(this);
}
companion object {
const val KEY_DEFAULT_ACTIVITY = "default_activity"
lateinit var context: Context
//debug模式开关,可显示更多调试信息
var debug = false
var warehouse: Warehouse? = null
fun getCurrentActivity(): BaseActivity<*> {
return ActivityCollector.activities[0]
}
fun setDefaultActivity() {
val activity: Activity = getCurrentActivity()
WmsSpf.saveData(KEY_DEFAULT_ACTIVITY, activity.javaClass.getName())
}
}
}