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

问题描述

我有一个应用程序包的名称。有没有什么办法让这个应用程序的图标,叫什么名字?包名例如:com.example.name

I have an application package name. Is there any way to get the icon, name of this application ?package name example: com.example.name

推荐答案

试着这么做:

    try {
        ApplicationInfo app = this.getPackageManager().getApplicationInfo("com.example.name", 0);

        Drawable icon = packageManager.getApplicationIcon(app);
        String name = packageManager.getApplicationLabel(app);
        return icon;
    } catch (NameNotFoundException e) {
        Toast toast = Toast.makeText(this, "error in getting icon", Toast.LENGTH_SHORT);
        toast.show();
        e.printStackTrace();
    }

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

08-20 10:15
查看更多