修复22.3.12后下拉天气显示异常

This commit is contained in:
乌堆小透明
2022-03-15 21:02:49 +08:00
parent 2f1930f704
commit 05493d35d4
3 changed files with 370 additions and 17 deletions

View File

@@ -0,0 +1,26 @@
package com.lt2333.simplicitytools.util
import android.content.Context
object SystemProperties {
operator fun get(context: Context, key: String?): String? {
var ret = ""
try {
val cl = context.classLoader
val SystemProperties = cl.loadClass("android.os.SystemProperties")
//参数类型
val paramTypes: Array<Class<*>?> = arrayOfNulls(1)
paramTypes[0] = String::class.java
val get = SystemProperties.getMethod("get", *paramTypes)
//参数
val params = arrayOfNulls<Any>(1)
params[0] = key
ret = get.invoke(SystemProperties, *params) as String
} catch (iAE: IllegalArgumentException) {
throw iAE
} catch (e: Exception) {
ret = ""
}
return ret
}
}