Alex
Alex

Reputation: 4774

Get App name from APK

I'm using php apk parser to get information from some apks uploaded to my website. The problem is I managed to get everything I need except the app's name.

I manage to get the package name, but not the app's name.

Is there any way to do it?

Thanks

Upvotes: 1

Views: 1046

Answers (1)

adelphus
adelphus

Reputation: 10326

The App's name is not a particularly well-defined value, but I'm going to assume you mean the label displayed on screen when the App is installed.

This is a non-trivial value to get for a couple of reasons:

  • The label is normally stored in localised resource files, allowing a different name to be displayed when Apps are installed on devices with different languages.
  • There's no guarantee that an App actually has a displayable icon or label - it's quite feasible to have Apps that do not display anything when installed and hence, have no name.

In any case, a couple of things you could try:

The parser does return an Application object - this object has a getLabel() method which returns the value of the label attribute (if any). It's highly likely that this value will be a reference to a string (rather than the actual string itself), so you may have to dig around to decode it.

Commonly, a label is defined with the main Activity that is run when the App is launched. To get that Activity, you will need to retrieve all the Activities from the Application object and work out which one is the launcher App by analysing the <intent-filter>s. When you find the right one, the label attribute on the Activity is what is displayed in Android.

You can hopefully see from all this that getting the display name is not simple, but perhaps the php-apk-parser project could be updated to make it a bit easier.

Upvotes: 2

Related Questions