In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "how to use Package Manager in Android". In daily operation, I believe many people have doubts about how to use Package Manager in Android. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubts about "how to use Package Manager in Android". Next, please follow the editor to study!
Preface
Android system provides us with many service management classes, including ActivityManager, PowerManager (Power Management) and AudioManager (Audio Management). PackageManager mainly manages the application package, through which you can obtain application information.
A Demo is written, which mainly realizes the acquisition of all the application information in the system, and the construction of Intent to start the corresponding application.
AndroidPackageDemo.7z
Introduction: AndroidManifest.xml file node description:
Introduction to related classes PackageManger class description: get information about installed applications. It can be obtained through the getPackageManager () method. Common method: public abstract PackageManager getPackageManager () function: get a PackageManger object public abstract Drawable getApplicationIcon (String packageName) parameter: packageName package name function: return the icon of a given package name, otherwise return null public abstract ApplicationInfo getApplicationInfo (String packageName, int flags) parameter: packagename package name flags the ApplicationInfo is the flags tag, usually you can directly give the constant 0 to function: return the ApplicationInfo object public abstract List getInstalledApplications (int flags) parameter: flag is generally GET_UNINSTALLED_PACKAGES Then all ApplicationInfo is returned at this time. We can filter the flags of ApplicationInfo to get what we need. Function: return all PackageInfopublic abstract List getInstalledPackages (int flags) parameters of a given condition as above: return all PackageInfopublic abstractResolveInfo resolveActivity (Intent intent, int flags) parameters of a given condition: intent lookup condition, action and category flags: MATCH_DEFAULT_ONLY: Category configured by Activity must have Activity of CATEGORY_DEFAULT Match GET_INTENT_FILTERS: match Intent condition GET_RESOLVED_FILTER: match Intent condition function: return the ResolveInfo object of a given condition (essentially Activity) public abstract List queryIntentActivities (Intent intent, int flags) parameters the same function as above: return all ResolveInfo objects of a given condition (essentially Activity) Collection object public abstract ResolveInfo resolveService (Intent intent, int flags) parameters the same function as above: return the ResolveInfo object (essentially Service) public abstract List queryIntentServices (Intent intent, int flags) parameters of the given condition: return all ResolveInfo objects (essentially Service) of the given condition, collection object PackageInfo class
Description: get the information of AndroidManifest.xml file manually.
Commonly used fields:
Public String packageName package name
Public ActivityInfo [] activities all node information
Public ApplicationInfo applicationInfo node information, only one
Public ActivityInfo [] receivers all node information, multiple
Public ServiceInfo [] services all node information, multiple
PackageItemInfo class
Description: the base class of all nodes in the AndroidManifest.xml file, which provides the basic information of these nodes: label, icon, meta-data. It doesn't.
Use it directly, but inherit it from the subclass and call the corresponding method.
The ApplicationInfo class inherits from PackageItemInfo
Description: get information about a node in a specific referenced program.
Field description: flags field: FLAG_SYSTEM system application, FLAG_EXTERNAL_STORAGE indicates that the application is installed in sdcard
Common methods inherit from loadIcon () and loadLabel () in the PackageItemInfo class
The ActivityInfo class inherits from PackageItemInfo
Description: get the information in the application or node. We can use it to get any properties we set, including
Theme, launchMode, launchmode, etc.
Common methods inherit from loadIcon () and loadLabel () in the PackageItemInfo class
ServiceInfo class
Description: similar to ActivityInfo, it inherits from PackageItemInfo, except that it represents node information.
ResolveInfo class
Description: according to the node to get its upper layer directory information, usually, node information.
At this point, the study on "how to use Package Manager in Android" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.