从Android包名称获取应用程序名称 [英] Get app name from package name in android

查看:181
本文介绍了从Android包名称获取应用程序名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想开发一款Android应用,可以列出所有的应用程序的有缓存,我顺利地拿到了有关高速缓存的信息,但现在我想显示其有一定的缓存在屏幕的应用程序,我有包名的,但问题是如何从包名称获取应用程序名称,

I'm trying to develop an android app that could list all app's which has cache, I successfully got the information about cache, but now I want to display those app which has some cache in the screen, I have the package name, but problem is how to get the application name from package name,

让我们说包名称为 com.android.browser
那么应用程序的名称将是浏览器

如何实现这一任务?

请不要介意,如果这个问题是愚蠢的你,请帮我解决这个谜团,
先谢谢了。

Please don't mind if this question is silly to you, please help me in solving this riddle, Thanks in advance.

推荐答案

您需要使用软件包管理系统来获取有关安装软件包的详细信息。

You need to use PackageManager to get detailed information about installed packages.

PackageManager packageManager = context.getPackageManager();
ApplicationInfo applicationInfo;
try {
    applicationInfo = packageManager.getApplicationInfo(packageName, 0);
} catch (final NameNotFoundException e) {}
final String title = (String)((applicationInfo != null) ? packageManager.getApplicationLabel(applicationInfo) : "???");

这篇关于从Android包名称获取应用程序名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆