Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
56f0c12b
D
Docs
项目概览
OpenHarmony
/
Docs
大约 2 年 前同步成功
通知
161
Star
293
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
56f0c12b
编写于
8月 30, 2023
作者:
O
openharmony_ci
提交者:
Gitee
8月 30, 2023
浏览文件
操作
浏览文件
下载
差异文件
!23532 ark警告修改——js-apis-Bundle.md部分
Merge pull request !23532 from zhouwenzhi/fix_ark
上级
fe26c3cb
d8c7db80
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
190 addition
and
93 deletion
+190
-93
zh-cn/application-dev/reference/apis/js-apis-Bundle.md
zh-cn/application-dev/reference/apis/js-apis-Bundle.md
+190
-93
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-Bundle.md
浏览文件 @
56f0c12b
...
@@ -58,13 +58,16 @@ SystemCapability.BundleManager.BundleFramework
...
@@ -58,13 +58,16 @@ SystemCapability.BundleManager.BundleFramework
**示例:**
**示例:**
```
ts
```
ts
let
bundleName
=
"
com.example.myapplication
"
;
import
bundle
from
'
@ohos.bundle
'
;
let
bundleFlags
=
0
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
userId
=
100
;
let
bundleName
:
string
=
"
com.example.myapplication
"
;
let
bundleFlags
:
number
=
0
;
let
userId
:
number
=
100
;
bundle
.
getApplicationInfo
(
bundleName
,
bundleFlags
,
userId
)
bundle
.
getApplicationInfo
(
bundleName
,
bundleFlags
,
userId
)
.
then
((
data
)
=>
{
.
then
((
data
)
=>
{
console
.
info
(
'
Operation successful. Data:
'
+
JSON
.
stringify
(
data
));
console
.
info
(
'
Operation successful. Data:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
error
)
=>
{
}).
catch
((
error
:
BusinessError
)
=>
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
error
));
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
error
));
})
})
```
```
...
@@ -99,9 +102,11 @@ SystemCapability.BundleManager.BundleFramework
...
@@ -99,9 +102,11 @@ SystemCapability.BundleManager.BundleFramework
**示例:**
**示例:**
```
ts
```
ts
let
bundleName
=
"
com.example.myapplication
"
;
import
bundle
from
'
@ohos.bundle
'
;
let
bundleFlags
=
0
;
let
userId
=
100
;
let
bundleName
:
string
=
"
com.example.myapplication
"
;
let
bundleFlags
:
number
=
0
;
let
userId
:
number
=
100
;
bundle
.
getApplicationInfo
(
bundleName
,
bundleFlags
,
userId
,
(
err
,
data
)
=>
{
bundle
.
getApplicationInfo
(
bundleName
,
bundleFlags
,
userId
,
(
err
,
data
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
err
));
...
@@ -141,8 +146,10 @@ SystemCapability.BundleManager.BundleFramework
...
@@ -141,8 +146,10 @@ SystemCapability.BundleManager.BundleFramework
**示例:**
**示例:**
```
ts
```
ts
let
bundleName
=
"
com.example.myapplication
"
;
import
bundle
from
'
@ohos.bundle
'
;
let
bundleFlags
=
0
;
let
bundleName
:
string
=
"
com.example.myapplication
"
;
let
bundleFlags
:
number
=
0
;
bundle
.
getApplicationInfo
(
bundleName
,
bundleFlags
,
(
err
,
data
)
=>
{
bundle
.
getApplicationInfo
(
bundleName
,
bundleFlags
,
(
err
,
data
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
err
));
...
@@ -185,13 +192,16 @@ SystemCapability.BundleManager.BundleFramework
...
@@ -185,13 +192,16 @@ SystemCapability.BundleManager.BundleFramework
**示例:**
**示例:**
```
ts
```
ts
let
bundleFlag
=
0
;
import
bundle
from
'
@ohos.bundle
'
;
let
userId
=
100
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
bundleFlag
:
number
=
0
;
let
userId
:
number
=
100
;
bundle
.
getAllBundleInfo
(
bundleFlag
,
userId
)
bundle
.
getAllBundleInfo
(
bundleFlag
,
userId
)
.
then
((
data
)
=>
{
.
then
((
data
)
=>
{
console
.
info
(
'
Operation successful. Data:
'
+
JSON
.
stringify
(
data
));
console
.
info
(
'
Operation successful. Data:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
error
)
=>
{
}).
catch
((
error
:
BusinessError
)
=>
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
error
));
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
error
));
})
})
```
```
...
@@ -223,7 +233,9 @@ SystemCapability.BundleManager.BundleFramework
...
@@ -223,7 +233,9 @@ SystemCapability.BundleManager.BundleFramework
**示例:**
**示例:**
```
ts
```
ts
let
bundleFlag
=
0
;
import
bundle
from
'
@ohos.bundle
'
;
let
bundleFlag
:
number
=
0
;
bundle
.
getAllBundleInfo
(
bundleFlag
,
(
err
,
data
)
=>
{
bundle
.
getAllBundleInfo
(
bundleFlag
,
(
err
,
data
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
err
));
...
@@ -262,8 +274,10 @@ SystemCapability.BundleManager.BundleFramework
...
@@ -262,8 +274,10 @@ SystemCapability.BundleManager.BundleFramework
**示例:**
**示例:**
```
ts
```
ts
let
bundleFlag
=
0
;
import
bundle
from
'
@ohos.bundle
'
;
let
userId
=
100
;
let
bundleFlag
:
number
=
0
;
let
userId
:
number
=
100
;
bundle
.
getAllBundleInfo
(
bundleFlag
,
userId
,
(
err
,
data
)
=>
{
bundle
.
getAllBundleInfo
(
bundleFlag
,
userId
,
(
err
,
data
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
err
));
...
@@ -309,15 +323,18 @@ SystemCapability.BundleManager.BundleFramework
...
@@ -309,15 +323,18 @@ SystemCapability.BundleManager.BundleFramework
**示例:**
**示例:**
```
ts
```
ts
let
bundleName
=
"
com.example.myapplication
"
;
import
bundle
from
'
@ohos.bundle
'
;
let
bundleFlags
=
1
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
options
=
{
let
bundleName
:
string
=
"
com.example.myapplication
"
;
let
bundleFlags
:
number
=
1
;
let
options
:
bundle
.
BundleOptions
=
{
"
userId
"
:
100
"
userId
"
:
100
};
};
bundle
.
getBundleInfo
(
bundleName
,
bundleFlags
,
options
)
bundle
.
getBundleInfo
(
bundleName
,
bundleFlags
,
options
)
.
then
((
data
)
=>
{
.
then
((
data
)
=>
{
console
.
info
(
'
Operation successful. Data:
'
+
JSON
.
stringify
(
data
));
console
.
info
(
'
Operation successful. Data:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
error
)
=>
{
}).
catch
((
error
:
BusinessError
)
=>
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
error
));
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
error
));
})
})
```
```
...
@@ -351,8 +368,10 @@ SystemCapability.BundleManager.BundleFramework
...
@@ -351,8 +368,10 @@ SystemCapability.BundleManager.BundleFramework
**示例:**
**示例:**
```
ts
```
ts
let
bundleName
=
"
com.example.myapplication
"
;
import
bundle
from
'
@ohos.bundle
'
;
let
bundleFlags
=
1
;
let
bundleName
:
string
=
"
com.example.myapplication
"
;
let
bundleFlags
:
number
=
1
;
bundle
.
getBundleInfo
(
bundleName
,
bundleFlags
,
(
err
,
data
)
=>
{
bundle
.
getBundleInfo
(
bundleName
,
bundleFlags
,
(
err
,
data
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
err
));
...
@@ -392,9 +411,11 @@ SystemCapability.BundleManager.BundleFramework
...
@@ -392,9 +411,11 @@ SystemCapability.BundleManager.BundleFramework
**示例:**
**示例:**
```
ts
```
ts
let
bundleName
=
"
com.example.myapplication
"
;
import
bundle
from
'
@ohos.bundle
'
;
let
bundleFlags
=
1
;
let
options
=
{
let
bundleName
:
string
=
"
com.example.myapplication
"
;
let
bundleFlags
:
number
=
1
;
let
options
:
bundle
.
BundleOptions
=
{
"
userId
"
:
100
"
userId
"
:
100
};
};
bundle
.
getBundleInfo
(
bundleName
,
bundleFlags
,
options
,
(
err
,
data
)
=>
{
bundle
.
getBundleInfo
(
bundleName
,
bundleFlags
,
options
,
(
err
,
data
)
=>
{
...
@@ -437,9 +458,12 @@ SystemCapability.BundleManager.BundleFramework
...
@@ -437,9 +458,12 @@ SystemCapability.BundleManager.BundleFramework
**示例:**
**示例:**
```
ts
```
ts
import
bundle
from
'
@ohos.bundle
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
bundle
.
getBundleInstaller
().
then
((
data
)
=>
{
bundle
.
getBundleInstaller
().
then
((
data
)
=>
{
console
.
info
(
'
getBundleInstaller successfully.
'
);
console
.
info
(
'
getBundleInstaller successfully.
'
);
}).
catch
((
error
)
=>
{
}).
catch
((
error
:
BusinessError
)
=>
{
console
.
error
(
'
getBundleInstaller failed.
'
);
console
.
error
(
'
getBundleInstaller failed.
'
);
});
});
```
```
...
@@ -473,6 +497,8 @@ SystemCapability.BundleManager.BundleFramework
...
@@ -473,6 +497,8 @@ SystemCapability.BundleManager.BundleFramework
**示例:**
**示例:**
```
ts
```
ts
import
bundle
from
'
@ohos.bundle
'
;
bundle
.
getBundleInstaller
((
err
,
data
)
=>
{
bundle
.
getBundleInstaller
((
err
,
data
)
=>
{
if
(
err
.
code
==
0
)
{
if
(
err
.
code
==
0
)
{
console
.
error
(
'
getBundleInstaller failed.
'
);
console
.
error
(
'
getBundleInstaller failed.
'
);
...
@@ -511,7 +537,9 @@ SystemCapability.BundleManager.BundleFramework
...
@@ -511,7 +537,9 @@ SystemCapability.BundleManager.BundleFramework
**示例:**
**示例:**
```
ts
```
ts
let
bundleName
=
"
com.example.myapplication
"
;
import
bundle
from
'
@ohos.bundle
'
;
let
bundleName
:
string
=
"
com.example.myapplication
"
;
bundle
.
cleanBundleCacheFiles
(
bundleName
,
err
=>
{
bundle
.
cleanBundleCacheFiles
(
bundleName
,
err
=>
{
if
(
err
)
{
if
(
err
)
{
...
@@ -557,11 +585,14 @@ SystemCapability.BundleManager.BundleFramework
...
@@ -557,11 +585,14 @@ SystemCapability.BundleManager.BundleFramework
**示例:**
**示例:**
```
ts
```
ts
let
bundleName
=
"
com.example.myapplication
"
;
import
bundle
from
'
@ohos.bundle
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
bundleName
:
string
=
"
com.example.myapplication
"
;
bundle
.
cleanBundleCacheFiles
(
bundleName
).
then
(()
=>
{
bundle
.
cleanBundleCacheFiles
(
bundleName
).
then
(()
=>
{
console
.
info
(
'
cleanBundleCacheFiles successfully.
'
);
console
.
info
(
'
cleanBundleCacheFiles successfully.
'
);
}).
catch
(
err
=>
{
}).
catch
(
(
error
:
BusinessError
)
=>
{
console
.
error
(
'
cleanBundleCacheFiles failed.
'
);
console
.
error
(
'
cleanBundleCacheFiles failed.
'
);
});
});
```
```
...
@@ -597,7 +628,9 @@ SystemCapability.BundleManager.BundleFramework
...
@@ -597,7 +628,9 @@ SystemCapability.BundleManager.BundleFramework
**示例:**
**示例:**
```
ts
```
ts
let
bundleName
=
"
com.example.myapplication
"
;
import
bundle
from
'
@ohos.bundle
'
;
let
bundleName
:
string
=
"
com.example.myapplication
"
;
bundle
.
setApplicationEnabled
(
bundleName
,
false
,
err
=>
{
bundle
.
setApplicationEnabled
(
bundleName
,
false
,
err
=>
{
if
(
err
)
{
if
(
err
)
{
...
@@ -644,11 +677,14 @@ SystemCapability.BundleManager.BundleFramework
...
@@ -644,11 +677,14 @@ SystemCapability.BundleManager.BundleFramework
**示例:**
**示例:**
```
ts
```
ts
let
bundleName
=
"
com.example.myapplication
"
;
import
bundle
from
'
@ohos.bundle
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
bundleName
:
string
=
"
com.example.myapplication
"
;
bundle
.
setApplicationEnabled
(
bundleName
,
false
).
then
(()
=>
{
bundle
.
setApplicationEnabled
(
bundleName
,
false
).
then
(()
=>
{
console
.
info
(
'
setApplicationEnabled successfully.
'
);
console
.
info
(
'
setApplicationEnabled successfully.
'
);
}).
catch
(
err
=>
{
}).
catch
(
(
error
:
BusinessError
)
=>
{
console
.
error
(
'
setApplicationEnabled failed.
'
);
console
.
error
(
'
setApplicationEnabled failed.
'
);
});
});
```
```
...
@@ -717,22 +753,21 @@ SystemCapability.BundleManager.BundleFramework
...
@@ -717,22 +753,21 @@ SystemCapability.BundleManager.BundleFramework
**示例:**
**示例:**
```
ts
```
ts
let
flag
=
bundle
.
BundleFlag
.
GET_ABILITY_INFO_WITH_PERMISSION
;
import
bundle
from
'
@ohos.bundle
'
;
let
userId
=
100
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
want
=
{
bundleName
:
"
com.example.myapplication
"
,
let
bundleName
:
string
=
"
com.example.myapplication
"
;
abilityName
:
"
EntryAbility
"
let
abilityName
:
string
=
"
EntryAbility
"
;
};
bundle
.
getAbilityInfo
(
want
,
flag
,
userId
).
then
((
abilityInfo
)
=>
{
bundle
.
getAbilityInfo
(
bundleName
,
abilityName
).
then
((
abilityInfo
)
=>
{
console
.
info
(
'
getAbilityInfo successfully. Data:
'
+
JSON
.
stringify
(
abilityInfo
));
console
.
info
(
'
getAbilityInfo successfully. Data:
'
+
JSON
.
stringify
(
abilityInfo
));
bundle
.
setAbilityEnabled
(
abilityInfo
,
false
).
then
(
data
=>
{
bundle
.
setAbilityEnabled
(
abilityInfo
,
false
).
then
(
data
=>
{
console
.
info
(
'
setAbilityEnabled successfully.
'
);
console
.
info
(
'
setAbilityEnabled successfully.
'
);
}).
catch
(
err
=>
{
}).
catch
(
(
error
:
BusinessError
)
=>
{
console
.
error
(
'
setAbilityEnabled failed:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
setAbilityEnabled failed:
'
+
JSON
.
stringify
(
err
or
));
})
})
}).
catch
(
error
=>
{
}).
catch
(
(
error
:
BusinessError
)
=>
{
console
.
error
(
'
getAbilityInfo failed. Cause:
'
+
JSON
.
stringify
(
error
));
console
.
error
(
'
getAbilityInfo failed. Cause:
'
+
JSON
.
stringify
(
error
));
});
});
```
```
...
@@ -766,7 +801,9 @@ SystemCapability.BundleManager.BundleFramework
...
@@ -766,7 +801,9 @@ SystemCapability.BundleManager.BundleFramework
**示例:**
**示例:**
```
ts
```
ts
let
permission
=
"
ohos.permission.GET_BUNDLE_INFO
"
;
import
bundle
from
'
@ohos.bundle
'
;
let
permission
:
string
=
"
ohos.permission.GET_BUNDLE_INFO
"
;
bundle
.
getPermissionDef
(
permission
,
(
err
,
data
)
=>
{
bundle
.
getPermissionDef
(
permission
,
(
err
,
data
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
'
getPermissionDef failed:
'
+
err
.
message
);
console
.
error
(
'
getPermissionDef failed:
'
+
err
.
message
);
...
@@ -811,10 +848,13 @@ SystemCapability.BundleManager.BundleFramework
...
@@ -811,10 +848,13 @@ SystemCapability.BundleManager.BundleFramework
**示例:**
**示例:**
```
ts
```
ts
let
permissionName
=
"
ohos.permission.GET_BUNDLE_INFO
"
;
import
bundle
from
'
@ohos.bundle
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
permissionName
:
string
=
"
ohos.permission.GET_BUNDLE_INFO
"
;
bundle
.
getPermissionDef
(
permissionName
).
then
((
data
)
=>
{
bundle
.
getPermissionDef
(
permissionName
).
then
((
data
)
=>
{
console
.
info
(
'
getPermissionDef successfully. Data:
'
+
JSON
.
stringify
(
data
));
console
.
info
(
'
getPermissionDef successfully. Data:
'
+
JSON
.
stringify
(
data
));
}).
catch
(
error
=>
{
}).
catch
(
(
error
:
BusinessError
)
=>
{
console
.
error
(
'
getPermissionDef failed. Cause:
'
+
error
.
message
);
console
.
error
(
'
getPermissionDef failed. Cause:
'
+
error
.
message
);
});
});
```
```
...
@@ -851,12 +891,15 @@ SystemCapability.BundleManager.BundleFramework
...
@@ -851,12 +891,15 @@ SystemCapability.BundleManager.BundleFramework
**示例:**
**示例:**
```
ts
```
ts
let
bundleFlags
=
8
;
import
bundle
from
'
@ohos.bundle
'
;
let
userId
=
100
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
bundleFlags
:
number
=
8
;
let
userId
:
number
=
100
;
bundle
.
getAllApplicationInfo
(
bundleFlags
,
userId
)
bundle
.
getAllApplicationInfo
(
bundleFlags
,
userId
)
.
then
((
data
)
=>
{
.
then
((
data
)
=>
{
console
.
info
(
'
Operation successful. Data:
'
+
JSON
.
stringify
(
data
));
console
.
info
(
'
Operation successful. Data:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
error
)
=>
{
}).
catch
((
error
:
BusinessError
)
=>
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
error
));
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
error
));
})
})
```
```
...
@@ -888,8 +931,10 @@ SystemCapability.BundleManager.BundleFramework
...
@@ -888,8 +931,10 @@ SystemCapability.BundleManager.BundleFramework
**示例:**
**示例:**
```
ts
```
ts
let
bundleFlags
=
bundle
.
BundleFlag
.
GET_APPLICATION_INFO_WITH_PERMISSION
;
import
bundle
from
'
@ohos.bundle
'
;
let
userId
=
100
;
let
bundleFlags
:
number
=
bundle
.
BundleFlag
.
GET_APPLICATION_INFO_WITH_PERMISSION
;
let
userId
:
number
=
100
;
bundle
.
getAllApplicationInfo
(
bundleFlags
,
userId
,
(
err
,
data
)
=>
{
bundle
.
getAllApplicationInfo
(
bundleFlags
,
userId
,
(
err
,
data
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
err
));
...
@@ -926,7 +971,9 @@ SystemCapability.BundleManager.BundleFramework
...
@@ -926,7 +971,9 @@ SystemCapability.BundleManager.BundleFramework
**示例:**
**示例:**
```
ts
```
ts
let
bundleFlags
=
bundle
.
BundleFlag
.
GET_APPLICATION_INFO_WITH_PERMISSION
;
import
bundle
from
'
@ohos.bundle
'
;
let
bundleFlags
:
number
=
bundle
.
BundleFlag
.
GET_APPLICATION_INFO_WITH_PERMISSION
;
bundle
.
getAllApplicationInfo
(
bundleFlags
,
(
err
,
data
)
=>
{
bundle
.
getAllApplicationInfo
(
bundleFlags
,
(
err
,
data
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
err
));
...
@@ -963,12 +1010,15 @@ SystemCapability.BundleManager.BundleFramework
...
@@ -963,12 +1010,15 @@ SystemCapability.BundleManager.BundleFramework
**示例:**
**示例:**
```
ts
```
ts
let
hapFilePath
=
"
/data/storage/el2/base/test.hap
"
;
import
bundle
from
'
@ohos.bundle
'
;
let
bundleFlags
=
0
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
hapFilePath
:
string
=
"
/data/storage/el2/base/test.hap
"
;
let
bundleFlags
:
number
=
0
;
bundle
.
getBundleArchiveInfo
(
hapFilePath
,
bundleFlags
)
bundle
.
getBundleArchiveInfo
(
hapFilePath
,
bundleFlags
)
.
then
((
data
)
=>
{
.
then
((
data
)
=>
{
console
.
info
(
'
Operation successful. Data:
'
+
JSON
.
stringify
(
data
));
console
.
info
(
'
Operation successful. Data:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
error
)
=>
{
}).
catch
((
error
:
BusinessError
)
=>
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
error
));
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
error
));
})
})
```
```
...
@@ -996,8 +1046,10 @@ SystemCapability.BundleManager.BundleFramework
...
@@ -996,8 +1046,10 @@ SystemCapability.BundleManager.BundleFramework
**示例:**
**示例:**
```
ts
```
ts
let
hapFilePath
=
"
/data/storage/el2/base/test.hap
"
;
import
bundle
from
'
@ohos.bundle
'
;
let
bundleFlags
=
0
;
let
hapFilePath
:
string
=
"
/data/storage/el2/base/test.hap
"
;
let
bundleFlags
:
number
=
0
;
bundle
.
getBundleArchiveInfo
(
hapFilePath
,
bundleFlags
,
(
err
,
data
)
=>
{
bundle
.
getBundleArchiveInfo
(
hapFilePath
,
bundleFlags
,
(
err
,
data
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
err
));
...
@@ -1041,12 +1093,15 @@ SystemCapability.BundleManager.BundleFramework
...
@@ -1041,12 +1093,15 @@ SystemCapability.BundleManager.BundleFramework
**示例:**
**示例:**
```
ts
```
ts
let
bundleName
=
"
com.example.myapplication
"
;
import
bundle
from
'
@ohos.bundle
'
;
let
abilityName
=
"
EntryAbility
"
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
bundleName
:
string
=
"
com.example.myapplication
"
;
let
abilityName
:
string
=
"
EntryAbility
"
;
bundle
.
getAbilityInfo
(
bundleName
,
abilityName
)
bundle
.
getAbilityInfo
(
bundleName
,
abilityName
)
.
then
((
data
)
=>
{
.
then
((
data
)
=>
{
console
.
info
(
'
Operation successful. Data:
'
+
JSON
.
stringify
(
data
));
console
.
info
(
'
Operation successful. Data:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
error
)
=>
{
}).
catch
((
error
:
BusinessError
)
=>
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
error
));
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
error
));
})
})
```
```
...
@@ -1080,8 +1135,10 @@ SystemCapability.BundleManager.BundleFramework
...
@@ -1080,8 +1135,10 @@ SystemCapability.BundleManager.BundleFramework
**示例:**
**示例:**
```
ts
```
ts
let
bundleName
=
"
com.example.myapplication
"
;
import
bundle
from
'
@ohos.bundle
'
;
let
abilityName
=
"
EntryAbility
"
;
let
bundleName
:
string
=
"
com.example.myapplication
"
;
let
abilityName
:
string
=
"
EntryAbility
"
;
bundle
.
getAbilityInfo
(
bundleName
,
abilityName
,
(
err
,
data
)
=>
{
bundle
.
getAbilityInfo
(
bundleName
,
abilityName
,
(
err
,
data
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
err
));
...
@@ -1125,12 +1182,15 @@ SystemCapability.BundleManager.BundleFramework
...
@@ -1125,12 +1182,15 @@ SystemCapability.BundleManager.BundleFramework
**示例:**
**示例:**
```
ts
```
ts
let
bundleName
=
"
com.example.myapplication
"
;
import
bundle
from
'
@ohos.bundle
'
;
let
abilityName
=
"
EntryAbility
"
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
bundleName
:
string
=
"
com.example.myapplication
"
;
let
abilityName
:
string
=
"
EntryAbility
"
;
bundle
.
getAbilityLabel
(
bundleName
,
abilityName
)
bundle
.
getAbilityLabel
(
bundleName
,
abilityName
)
.
then
((
data
)
=>
{
.
then
((
data
)
=>
{
console
.
info
(
'
Operation successful. Data:
'
+
JSON
.
stringify
(
data
));
console
.
info
(
'
Operation successful. Data:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
error
)
=>
{
}).
catch
((
error
:
BusinessError
)
=>
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
error
));
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
error
));
})
})
```
```
...
@@ -1164,8 +1224,10 @@ SystemCapability.BundleManager.BundleFramework
...
@@ -1164,8 +1224,10 @@ SystemCapability.BundleManager.BundleFramework
**示例:**
**示例:**
```
ts
```
ts
let
bundleName
=
"
com.example.myapplication
"
;
import
bundle
from
'
@ohos.bundle
'
;
let
abilityName
=
"
EntryAbility
"
;
let
bundleName
:
string
=
"
com.example.myapplication
"
;
let
abilityName
:
string
=
"
EntryAbility
"
;
bundle
.
getAbilityLabel
(
bundleName
,
abilityName
,
(
err
,
data
)
=>
{
bundle
.
getAbilityLabel
(
bundleName
,
abilityName
,
(
err
,
data
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
err
));
...
@@ -1202,12 +1264,15 @@ SystemCapability.BundleManager.BundleFramework
...
@@ -1202,12 +1264,15 @@ SystemCapability.BundleManager.BundleFramework
**示例:**
**示例:**
```
ts
```
ts
let
bundleName
=
"
com.example.myapplication
"
;
import
bundle
from
'
@ohos.bundle
'
;
let
abilityName
=
"
EntryAbility
"
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
bundleName
:
string
=
"
com.example.myapplication
"
;
let
abilityName
:
string
=
"
EntryAbility
"
;
bundle
.
getAbilityInfo
(
bundleName
,
abilityName
).
then
((
abilityInfo
)
=>
{
bundle
.
getAbilityInfo
(
bundleName
,
abilityName
).
then
((
abilityInfo
)
=>
{
bundle
.
isAbilityEnabled
(
abilityInfo
).
then
((
data
)
=>
{
bundle
.
isAbilityEnabled
(
abilityInfo
).
then
((
data
)
=>
{
console
.
info
(
'
Operation successful. Data:
'
+
JSON
.
stringify
(
data
));
console
.
info
(
'
Operation successful. Data:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
error
)
=>
{
}).
catch
((
error
:
BusinessError
)
=>
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
error
));
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
error
));
})
})
})
})
...
@@ -1235,8 +1300,10 @@ SystemCapability.BundleManager.BundleFramework
...
@@ -1235,8 +1300,10 @@ SystemCapability.BundleManager.BundleFramework
**示例:**
**示例:**
```
ts
```
ts
let
bundleName
=
"
com.example.myapplication
"
;
import
bundle
from
'
@ohos.bundle
'
;
let
abilityName
=
"
EntryAbility
"
;
let
bundleName
:
string
=
"
com.example.myapplication
"
;
let
abilityName
:
string
=
"
EntryAbility
"
;
bundle
.
getAbilityInfo
(
bundleName
,
abilityName
).
then
((
abilityInfo
)
=>
{
bundle
.
getAbilityInfo
(
bundleName
,
abilityName
).
then
((
abilityInfo
)
=>
{
bundle
.
isAbilityEnabled
(
abilityInfo
,
(
err
,
data
)
=>
{
bundle
.
isAbilityEnabled
(
abilityInfo
,
(
err
,
data
)
=>
{
if
(
err
)
{
if
(
err
)
{
...
@@ -1275,11 +1342,14 @@ SystemCapability.BundleManager.BundleFramework
...
@@ -1275,11 +1342,14 @@ SystemCapability.BundleManager.BundleFramework
**示例:**
**示例:**
```
ts
```
ts
let
bundleName
=
"
com.example.myapplication
"
;
import
bundle
from
'
@ohos.bundle
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
bundleName
:
string
=
"
com.example.myapplication
"
;
bundle
.
isApplicationEnabled
(
bundleName
)
bundle
.
isApplicationEnabled
(
bundleName
)
.
then
((
data
)
=>
{
.
then
((
data
)
=>
{
console
.
info
(
'
Operation successful. Data:
'
+
JSON
.
stringify
(
data
));
console
.
info
(
'
Operation successful. Data:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
error
)
=>
{
}).
catch
((
error
:
BusinessError
)
=>
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
error
));
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
error
));
})
})
```
```
...
@@ -1306,7 +1376,9 @@ SystemCapability.BundleManager.BundleFramework
...
@@ -1306,7 +1376,9 @@ SystemCapability.BundleManager.BundleFramework
**示例:**
**示例:**
```
ts
```
ts
let
bundleName
=
"
com.example.myapplication
"
;
import
bundle
from
'
@ohos.bundle
'
;
let
bundleName
:
string
=
"
com.example.myapplication
"
;
bundle
.
isApplicationEnabled
(
bundleName
,
(
err
,
data
)
=>
{
bundle
.
isApplicationEnabled
(
bundleName
,
(
err
,
data
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
err
));
...
@@ -1351,16 +1423,20 @@ SystemCapability.BundleManager.BundleFramework
...
@@ -1351,16 +1423,20 @@ SystemCapability.BundleManager.BundleFramework
**示例:**
**示例:**
```
ts
```
ts
let
bundleFlags
=
0
;
import
bundle
from
'
@ohos.bundle
'
;
let
userId
=
100
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
want
=
{
import
Want
from
'
@ohos.app.ability.Want
'
;
let
bundleFlags
:
number
=
0
;
let
userId
:
number
=
100
;
let
want
:
Want
=
{
bundleName
:
"
com.example.myapplication
"
,
bundleName
:
"
com.example.myapplication
"
,
abilityName
:
"
EntryAbility
"
abilityName
:
"
EntryAbility
"
};
};
bundle
.
queryAbilityByWant
(
want
,
bundleFlags
,
userId
)
bundle
.
queryAbilityByWant
(
want
,
bundleFlags
,
userId
)
.
then
((
data
)
=>
{
.
then
((
data
)
=>
{
console
.
info
(
'
Operation successful. Data:
'
+
JSON
.
stringify
(
data
));
console
.
info
(
'
Operation successful. Data:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
error
)
=>
{
}).
catch
((
error
:
BusinessError
)
=>
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
error
));
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
error
));
})
})
```
```
...
@@ -1397,9 +1473,12 @@ SystemCapability.BundleManager.BundleFramework
...
@@ -1397,9 +1473,12 @@ SystemCapability.BundleManager.BundleFramework
**示例:**
**示例:**
```
ts
```
ts
let
bundleFlags
=
0
;
import
bundle
from
'
@ohos.bundle
'
;
let
userId
=
100
;
import
Want
from
'
@ohos.app.ability.Want
'
;
let
want
=
{
let
bundleFlags
:
number
=
0
;
let
userId
:
number
=
100
;
let
want
:
Want
=
{
bundleName
:
"
com.example.myapplication
"
,
bundleName
:
"
com.example.myapplication
"
,
abilityName
:
"
EntryAbility
"
abilityName
:
"
EntryAbility
"
};
};
...
@@ -1441,8 +1520,11 @@ SystemCapability.BundleManager.BundleFramework
...
@@ -1441,8 +1520,11 @@ SystemCapability.BundleManager.BundleFramework
**示例:**
**示例:**
```
ts
```
ts
let
bundleFlags
=
0
;
import
bundle
from
'
@ohos.bundle
'
;
let
want
=
{
import
Want
from
'
@ohos.app.ability.Want
'
;
let
bundleFlags
:
number
=
0
;
let
want
:
Want
=
{
bundleName
:
"
com.example.myapplication
"
,
bundleName
:
"
com.example.myapplication
"
,
abilityName
:
"
EntryAbility
"
abilityName
:
"
EntryAbility
"
};
};
...
@@ -1487,11 +1569,14 @@ SystemCapability.BundleManager.BundleFramework
...
@@ -1487,11 +1569,14 @@ SystemCapability.BundleManager.BundleFramework
**示例:**
**示例:**
```
ts
```
ts
let
bundleName
=
"
com.example.myapplication
"
;
import
bundle
from
'
@ohos.bundle
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
bundleName
:
string
=
"
com.example.myapplication
"
;
bundle
.
getLaunchWantForBundle
(
bundleName
)
bundle
.
getLaunchWantForBundle
(
bundleName
)
.
then
((
data
)
=>
{
.
then
((
data
)
=>
{
console
.
info
(
'
Operation successful. Data:
'
+
JSON
.
stringify
(
data
));
console
.
info
(
'
Operation successful. Data:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
error
)
=>
{
}).
catch
((
error
:
BusinessError
)
=>
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
error
));
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
error
));
})
})
```
```
...
@@ -1522,7 +1607,9 @@ SystemCapability.BundleManager.BundleFramework
...
@@ -1522,7 +1607,9 @@ SystemCapability.BundleManager.BundleFramework
**示例:**
**示例:**
```
ts
```
ts
let
bundleName
=
"
com.example.myapplication
"
;
import
bundle
from
'
@ohos.bundle
'
;
let
bundleName
:
string
=
"
com.example.myapplication
"
;
bundle
.
getLaunchWantForBundle
(
bundleName
,
(
err
,
data
)
=>
{
bundle
.
getLaunchWantForBundle
(
bundleName
,
(
err
,
data
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
err
));
...
@@ -1559,11 +1646,14 @@ SystemCapability.BundleManager.BundleFramework
...
@@ -1559,11 +1646,14 @@ SystemCapability.BundleManager.BundleFramework
**示例:**
**示例:**
```
ts
```
ts
let
uid
=
20010005
;
import
bundle
from
'
@ohos.bundle
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
uid
:
number
=
20010005
;
bundle
.
getNameForUid
(
uid
)
bundle
.
getNameForUid
(
uid
)
.
then
((
data
)
=>
{
.
then
((
data
)
=>
{
console
.
info
(
'
Operation successful. Data:
'
+
JSON
.
stringify
(
data
));
console
.
info
(
'
Operation successful. Data:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
error
)
=>
{
}).
catch
((
error
:
BusinessError
)
=>
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
error
));
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
error
));
})
})
```
```
...
@@ -1590,7 +1680,9 @@ SystemCapability.BundleManager.BundleFramework
...
@@ -1590,7 +1680,9 @@ SystemCapability.BundleManager.BundleFramework
**示例:**
**示例:**
```
ts
```
ts
let
uid
=
20010005
;
import
bundle
from
'
@ohos.bundle
'
;
let
uid
:
number
=
20010005
;
bundle
.
getNameForUid
(
uid
,
(
err
,
data
)
=>
{
bundle
.
getNameForUid
(
uid
,
(
err
,
data
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
err
));
...
@@ -1634,12 +1726,15 @@ SystemCapability.BundleManager.BundleFramework
...
@@ -1634,12 +1726,15 @@ SystemCapability.BundleManager.BundleFramework
**示例:**
**示例:**
```
ts
```
ts
let
bundleName
=
"
com.example.myapplication
"
;
import
bundle
from
'
@ohos.bundle
'
;
let
abilityName
=
"
EntryAbility
"
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
bundleName
:
string
=
"
com.example.myapplication
"
;
let
abilityName
:
string
=
"
EntryAbility
"
;
bundle
.
getAbilityIcon
(
bundleName
,
abilityName
)
bundle
.
getAbilityIcon
(
bundleName
,
abilityName
)
.
then
((
data
)
=>
{
.
then
((
data
)
=>
{
console
.
info
(
'
Operation successful. Data:
'
+
JSON
.
stringify
(
data
));
console
.
info
(
'
Operation successful. Data:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
error
)
=>
{
}).
catch
((
error
:
BusinessError
)
=>
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
error
));
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
error
));
})
})
```
```
...
@@ -1674,8 +1769,10 @@ SystemCapability.BundleManager.BundleFramework
...
@@ -1674,8 +1769,10 @@ SystemCapability.BundleManager.BundleFramework
**示例:**
**示例:**
```
ts
```
ts
let
bundleName
=
"
com.example.myapplication
"
;
import
bundle
from
'
@ohos.bundle
'
;
let
abilityName
=
"
EntryAbility
"
;
let
bundleName
:
string
=
"
com.example.myapplication
"
;
let
abilityName
:
string
=
"
EntryAbility
"
;
bundle
.
getAbilityIcon
(
bundleName
,
abilityName
,
(
err
,
data
)
=>
{
bundle
.
getAbilityIcon
(
bundleName
,
abilityName
,
(
err
,
data
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Operation failed. Cause:
'
+
JSON
.
stringify
(
err
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录