From 847576758929123fee8e49e578aa749c3d866ce4 Mon Sep 17 00:00:00 2001 From: "taohebin@dcloud.io" Date: Wed, 17 Apr 2024 15:57:22 +0800 Subject: [PATCH] Update uts-for-android.md --- docs/plugin/uts-for-android.md | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/docs/plugin/uts-for-android.md b/docs/plugin/uts-for-android.md index 8c5f8785..526cec96 100644 --- a/docs/plugin/uts-for-android.md +++ b/docs/plugin/uts-for-android.md @@ -1271,7 +1271,23 @@ ScancodeConfig.setShowLine(false); ScancodeConfig.showLine = false; ``` - +### 6.14 Android原生API过时警告处理 + +调用原生过时的API插件编译时产生警告,可以使用`@Suppress("DEPRECATION")`添加注解到使用的方法上忽略警告,例: +```js +@Suppress("DEPRECATION") +function getAppName(context : Context) : string { + let appName = "" + try { + const packageManager = context.getPackageManager() + const applicationInfo = packageManager.getApplicationInfo(context.getPackageName(), 0) + appName = packageManager.getApplicationLabel(applicationInfo) as string + } catch (e : Exception) { + e.printStackTrace() + } + return appName +} +``` ## 7 已知待解决问题(持续更新) -- GitLab