从零开始学安卓(kotlin)十二——高级技巧

阅读 51

2022-04-25

目录

全局获取Context

创建MyApplication类,用MyApplication.context获取

import android.annotation.SuppressLint
import android.app.Application
import android.content.Context

class MyApplication : Application() {
    companion object {
        @SuppressLint("StaticFieldLeak")
        lateinit var context: Context
    }
    override fun onCreate() {

        super.onCreate()
        context = applicationContext

    }
}

git管理

git add .
git commit -m "xxx commit."
git push

精彩评论(0)

0 0 举报