已合并
add getOsAccountNameByLocalId #135094
yeyuning创建于 3月20日
add getOsAccountNameByLocalId #135094
已合并
yeyuning创建于 3月20日
1 个文件变更+55-0
@@ -3017,6 +3017,61 @@ getOsAccountName(): Promise<string>
3017 }3017 }
3018 ```3018 ```
3019 3019 
3020+### getOsAccountNameByLocalId
3021+ 
3022+getOsAccountNameByLocalId(localId: number): Promise<string>
3023+ 
3024+根据系统账号的本地ID获取系统账号的名称。使用Promise异步回调。
3025+ 
x_huahua
x_huahuax_huahua3月27日
改动建议
3025
+ **起始版本**:26.0.0
3026
+
3027
+ **模型约束**:此接口仅可在FA模型下使用。
应用建议

26开始不加角标了 所有字段都要体现

likedislike
3026+**起始版本**:26.0.0
3027+ 
3028+**模型约束**:此接口仅可在Stage模型下使用。
3029+ 
3030+**需要权限:** ohos.permission.GET_LOCAL_ACCOUNT_IDENTIFIERS
3031+ 
3032+**系统能力:** SystemCapability.Account.OsAccount
3033+ 
3034+**参数:**
3035+ 
3036+| 参数名 | 类型 | 必填 | 说明 |
3037+| -------- | ------ | ---- | ----------------------- |
3038+| localId | number | 是 | 目标系统账号的本地ID。 |
3039+ 
3040+**返回值:**
3041+ 
3042+| 类型 | 说明 |
3043+| ------------------- | ----------------------- |
3044+| Promise<string> | Promise对象,返回目标系统账号的名称。 |
3045+ 
3046+**错误码:**
3047+ 
3048+以下错误码的详细介绍请参见[账号管理错误码](errorcode-account.md)和[通用错误码](../errorcode-universal.md)。
3049+ 
3050+| 错误码ID | 错误信息 |
3051+| -------- | --------------------------- |
3052+| 201 | Permission denied. |
3053+| 12300001 | The system service works abnormally. |
3054+| 12300003 | Account not found. |
3055+| 12300008 | Restricted Account. |
3056+ 
3057+**示例:**
3058+ 
3059+```ts
3060+import { BusinessError } from '@kit.BasicServicesKit';
3061+ 
3062+let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
3063+try {
3064+ accountManager.getOsAccountNameByLocalId(100).then((name: string) => {
3065+ console.info('getOsAccountNameByLocalId, name: ' + name);
3066+ }).catch((err: BusinessError) => {
3067+ console.error('getOsAccountNameByLocalId err: ' + err);
3068+ });
3069+} catch (e) {
3070+ const err = e as BusinessError;
3071+ console.error(`getOsAccountNameByLocalId exception: code is ${err.code}, message is ${err.message}`);
3072+}
3073+```
3074+ 
3020### getForegroundOsAccountLocalId<sup>15+</sup>3075### getForegroundOsAccountLocalId<sup>15+</sup>
3021 3076 
3022getForegroundOsAccountLocalId(): Promise&lt;number&gt;3077getForegroundOsAccountLocalId(): Promise&lt;number&gt;