Android 反射

复制代码
fun getPrivateValue(device: BluetoothDevice?):Int{
    try {
        val activityManagerClass =
            Class.forName("android.bluetooth.BluetoothDevice")//类名
        val getCurrentUserMethod =
            activityManagerClass.getMethod("getAdapterIndex")//方法
        return getCurrentUserMethod.invoke(device) as Int
    }catch (e: Exception){
        LogUtils.d(TAG,"error")
    }
    return -1
}
相关推荐
Le_ee5 小时前
SWPUCTF 2025 秋季新生赛wp2
android
前端之虎陈随易5 小时前
为什么今天还会有新语言?MoonBit 想解决什么问题?
大数据·linux·javascript·人工智能·算法·microsoft·typescript
kyriewen5 小时前
你等的Babel编译,够喝三杯咖啡了——用Rust重写的SWC,只需眨个眼
前端·javascript·rust
搬砖码5 小时前
同源多标签页通信 4 种方案,从入门到生产环境
前端·面试
张元清5 小时前
SSR 状态管理陷阱:defineStore vs defineContextStore
前端·javascript·面试
donecoding6 小时前
nrm、corepack、npm registry 三者的爱恨情仇
前端·node.js·前端工程化
小gaigagi6 小时前
从吉客云·奇门到MySQL的完整数据流
前端
悟空瞎说6 小时前
用 Rust 开发 QML 桌面应用(第二篇)—— 日志系统完整搭建
前端
LIO6 小时前
前端开发之Git 代码仓库管理详细教程
前端·git
软件开发技术深度爱好者6 小时前
前端网页开发三剑客快速入门
前端