Difference between ApplicationInfo and PackageInfo?
Asked Answered
P

2

19

I have several general question about ApplicationInfo and PackageInfo classes. Here they are:

  1. Can someone describe the difference between ApplicationInfo and PackageInfo?
  2. How do they correlate with each other?
  3. In which cases ApplicationInfo is used and when PackageInfo is used?

Thank you for the help!

EDIT:

First of all, before posting such a question I've read official documentation and googled. Here are some additional questions that are unclear to me. Sorry, maybe I did not ask them appropriately:

  1. PackageInfo can have ApplicationInfo object with NULL value. When it is possible? (I guess this is connected with the uninstalled packages)
  2. ApplicationInfo contains uid of the application. Is it possible that PackageInfo does not have uid (when ApplicationInfo is null?).

So these kind of questions. I do not understand these connections.

Premeditation answered 10/7, 2012 at 8:46 Comment(0)
M
32
  1. Can someone describe the difference between ApplicationInfo and PackageInfo?

    PackageInfo represents the entire AndroidManifest.xml.ApplicationInfo is actually a field/attribute of PackageInfo,refering only to the application tag. Refer this.

  2. How do they correlate with each other?

    As I mentioned ApplicationInfo is actually an attribute/field of PackageInfo which itself happens to be a complex object and has its own methods/fields.

  3. In which cases ApplicationInfo is used and when PackageInfo is used?

    To access information within application tag which could be related to services or actvities or broadcast receivers we use ApplicationInfo.Data related to the rest of the AndroidManifest.xml can be obtained via the other fields/methods in PackageInfo class

Mutate answered 10/7, 2012 at 9:2 Comment(1)
Very good answer, so Upvote. Why this is not selected answer?Buehrer
M
3

PackageInfo contains ApplicationInfo (PackageInfo.applicationInfo).

Package info is all your info from your manifest file, ApplicaitonInfo is the info from the <application> tag in your manifest.

When they are used? it depends on which info you a looking for , or which API methods you are using.

Macrography answered 10/7, 2012 at 8:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.