知识点

[图片上传中...(32411620824778_.pic.jpg-5ff572-1620826945526-0)]

32411620824778_.pic.jpg

32421620826204_.pic_hd.jpg

32431620826576_.pic_hd.jpg

确保设备是否有外部存储

fun judgeCard() {
        if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
            
        }
    }
android6.0以上需要动态申请权限
 fun requestPermission() {
        val permission = ContextCompat.checkSelfPermission(
            this,
            Manifest.permission.WRITE_EXTERNAL_STORAGE
        )
        if (permission != PackageManager.PERMISSION_GRANTED) {
            //动态申请权限
            ActivityCompat.requestPermissions(
                this,
                arrayOf(Manifest.permission.WRITE_EXTERNAL_STORAGE),
                1
            )
        }
    }

    //当动态申请权限的过程中 requestCode等于几 做什么操作
    override fun onRequestPermissionsResult(
        requestCode: Int,
        permissions: Array,
        grantResults: IntArray
    ) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults)
        if (requestCode == 1) {

        }
    }

Environment.getExternalStorageDirectory() 获取的目录才是sdcard的实际目录(系统不同会造成路径有差异)

继承Thread和实现Runnable接口的区别

image.png

Application对象和静态单列的区别

WeChatf6bc506c6276bb2b26d20b34b41cc1d4.png

WeChat771200f9af0968e095a182428fb5f808.png

你可能感兴趣的:(知识点)