新聞中心
LauncherService

創(chuàng)新互聯(lián)是一家業(yè)務(wù)范圍包括IDC托管業(yè)務(wù),網(wǎng)站空間、主機(jī)租用、主機(jī)托管,四川、重慶、廣東電信服務(wù)器租用,達(dá)州托管服務(wù)器,成都網(wǎng)通服務(wù)器托管,成都服務(wù)器租用,業(yè)務(wù)范圍遍及中國大陸、港澳臺以及歐美等多個國家及地區(qū)的互聯(lián)網(wǎng)數(shù)據(jù)服務(wù)公司。
java.lang.Object
|---ohos.bundle.LauncherService
public class LauncherService
extends Object查詢車輛的啟動器ability和應(yīng)用信息。
你可以使用這個類來注冊一個回調(diào)方法來觀察bundle狀態(tài)的變化。
嵌套類摘要
| 修飾符和類型 | 類 | 描述 |
|---|---|---|
| static class | LauncherService.BundleStatusCallback | 提供在安裝、卸載或更新捆綁包后調(diào)用的回調(diào)方法。 |
構(gòu)造函數(shù)摘要
| 構(gòu)造函數(shù) | 描述 |
|---|---|
| LauncherService(Context context) | 用于創(chuàng)建 LauncherService 實(shí)例的構(gòu)造函數(shù)。 |
方法總結(jié)
| 修飾符和類型 | 方法 | 描述 |
|---|---|---|
| OptionalLauncherAbilityInfo | getAbilityInfo(Intent intent, int userId) | 根據(jù)給定 Intent 中指定的 ElementName 和 userId 獲取啟動器ability。 |
| OptionalListLauncherAbilityInfo | getAbilityList(String bundleName, int userId) | 根據(jù)包含 Intent.ACTION_HOME 和 Intent.ENTITY_HOME 的 Intent 獲取啟動器ability。 |
| OptionalApplicationInfo | getApplicationInfo(String bundleName, int flags, int userId) | 根據(jù)給定的包名稱、標(biāo)志和用戶 ID 獲取有關(guān)應(yīng)用程序的信息。 |
| OptionalListLauncherShortcutInfo | getShortcutInfos(String bundleName) | 獲取有關(guān)應(yīng)用程序快捷方式的信息。 |
| boolean | isAbilityEnabled(AbilityInfo abilityInfo) | 檢查ability是否存在并啟用。 |
| boolean | isBundleEnabled(String bundleName) | 檢查捆綁包是否存在并已啟用。 |
| void | registerCallback(LauncherService.BundleStatusCallback callback) | 注冊一個回調(diào)方法,用于監(jiān)控包安裝、卸載和更新事件。 |
| void | startShortcut(String shortcutId, String bundleName) | 根據(jù)給定的快捷方式 ID 和包名稱啟動快捷方式。 |
| void | unRegisterCallback() | 取消注冊用于監(jiān)視捆綁安裝、卸載和更新事件的回調(diào)方法。 |
| 從類 java.lang.Object 繼承的方法 |
|---|
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
構(gòu)造函數(shù)詳細(xì)信息
LauncherService
public LauncherService(Context context)
用于創(chuàng)建 LauncherService 實(shí)例的構(gòu)造函數(shù)。
您可以使用此實(shí)例注冊回調(diào)方法以監(jiān)視捆綁包安裝、卸載和更新事件。
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| context | 表示當(dāng)前ability的上下文對象。 |
方法詳情
registerCallback
public void registerCallback(LauncherService.BundleStatusCallback callback)
注冊一個回調(diào)方法,用于監(jiān)控包安裝、卸載和更新事件。
要使用此方法,您需要向系統(tǒng)請求 ohos.permission.LISTEN_BUNDLE_CHANGE 權(quán)限。 ohos.permission.LISTEN_BUNDLE_CHANGE 權(quán)限屬于簽名|特權(quán)級別。
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| callback | 表示要調(diào)用的回調(diào)方法。 |
unRegisterCallback
public void unRegisterCallback()
取消注冊用于監(jiān)視捆綁安裝、卸載和更新事件的回調(diào)方法。
getAbilityList
public OptionalListLauncherAbilityInfo getAbilityList(String bundleName, int userId)
根據(jù)包含 Intent.ACTION_HOME 和 Intent.ENTITY_HOME 的 Intent 獲取啟動器ability。
如果指定了包名稱,則返回有關(guān)與指定包匹配的啟動器ability的信息。 否則,將返回有關(guān)與 Intent 匹配的所有啟動器ability的信息。
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| bundleName | 指示捆綁包名稱。 |
| userId | 表示用戶標(biāo)識。 |
返回:
返回 LauncherAbilityInfo 對象的列表。
getAbilityInfo
public OptionalLauncherAbilityInfo getAbilityInfo(Intent intent, int userId)
根據(jù)給定 Intent 中指定的 ElementName 和 userId 獲取啟動器ability。
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| intent | 指示包含要查詢的應(yīng)用程序包名稱的 Intent。 |
| userId | 表示用戶標(biāo)識。 |
返回:
返回一個 LauncherAbilityInfo 對象。
getApplicationInfo
public OptionalApplicationInfo getApplicationInfo(String bundleName, int flags, int userId)
根據(jù)給定的包名稱、標(biāo)志和用戶 ID 獲取有關(guān)應(yīng)用程序的信息。
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| bundleName | 表示要查詢的bundle名稱。 |
| flags | 指示用于指定將返回的 ApplicationInfo 對象中包含的信息的標(biāo)志。 |
| userId | 表示用戶標(biāo)識。 |
返回:
返回一個 ApplicationInfo 對象。
isBundleEnabled
public boolean isBundleEnabled(String bundleName)
檢查捆綁包是否存在并已啟用。
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| bundleName | 指示捆綁包名稱。 |
返回:
如果啟用了捆綁包,則返回 true; 否則返回 false。
isAbilityEnabled
public boolean isAbilityEnabled(AbilityInfo abilityInfo)
檢查ability是否存在并啟用。
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| abilityInfo | 表示有關(guān)檢查ability的信息。 |
返回:
如果該ability存在且已啟用,則返回 true; 否則返回 false。
getShortcutInfos
public OptionalListLauncherShortcutInfo getShortcutInfos(String bundleName)
獲取有關(guān)應(yīng)用程序快捷方式的信息。
要使用此方法,您需要向系統(tǒng)請求 ohos.permission.MANAGE_SHORTCUTS 權(quán)限。 ohos.permission.MANAGE_SHORTCUTS 權(quán)限屬于簽名級別。
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| bundleName | 指示應(yīng)用程序的捆綁包名稱。 |
返回:
返回包含有關(guān)應(yīng)用程序的快捷方式信息的 LauncherShortcutInfo 對象列表。
startShortcut
public void startShortcut(String shortcutId, String bundleName)
根據(jù)給定的快捷方式 ID 和包名稱啟動快捷方式。
要使用此方法,您需要向系統(tǒng)請求 ohos.permission.MANAGE_SHORTCUTS 權(quán)限。 ohos.permission.MANAGE_SHORTCUTS 權(quán)限屬于簽名級別。
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| shortcutId | 指示要啟動的快捷方式的 ID。 |
| bundleName | BundleName 表示快捷方式所屬的應(yīng)用程序的包名。 |
文章題目:創(chuàng)新互聯(lián)鴻蒙OS教程:鴻蒙OSLauncherService
本文鏈接:http://m.fisionsoft.com.cn/article/djjhhjd.html


咨詢
建站咨詢
