Get package names and class names for all applications

后端 未结 2 968
迷失自我
迷失自我 2021-01-20 14:43

Does anyone know the class name and package name for any of these applications:

youtube facebook amazon mp3 google talk camera maps text message dialer/phone launche

相关标签:
2条回答
  • 2021-01-20 14:52
    class PInfo {
        private String appname = "";
        private String pname = "";
        private String classname = "";
        private int versionCode = 0;
        private Drawable icon;
        private void prettyPrint() {
            Log.d("Applist ",appname + "   " + pname + "   " + classname + "   " + versionCode);
    
        }
    }
    
    
    
    
    
    public ArrayList<PInfo> getPackages() {
         Log.d("AppNo", "Inside Packages"); 
        ArrayList<PInfo> apps = getInstalledApps(false); /* false = no system packages */
        final int max = apps.size();
        Log.d("AppNo", "no of apps "+max); 
        for (int i=0; i<max; i++) {
            apps.get(i).prettyPrint();
    
        }
        return apps;
    }
    
    public ArrayList<PInfo> getInstalledApps(boolean getSysPackages) {
        ArrayList<PInfo> res = new ArrayList<PInfo>();        
        List<PackageInfo> packs = getPackageManager().getInstalledPackages(0);
        for(int i=0;i<packs.size();i++) {
            PackageInfo p = packs.get(i);
    
    
    
            if ((!getSysPackages) && (p.versionName == null)) {
                continue ;
            }
            PInfo newInfo = new PInfo();
            newInfo.appname = p.applicationInfo.loadLabel(getPackageManager()).toString();
            newInfo.pname = p.packageName;
            newInfo.classname = p.applicationInfo.className;
            newInfo.versionCode = p.versionCode;
            newInfo.icon = p.applicationInfo.loadIcon(getPackageManager());
    
            Intent app=getPackageManager().getLaunchIntentForPackage(p.packageName);
    
    
                if(app!=null){
                    dleteintent(app,newInfo.appname, newInfo.icon);
                    res.add(newInfo);
            }
    
        }
        return res;
    

    }

    Using PakageInfo you can get package name, application Name but not sure about application class name

    Using this example you can list all applications install in your device and can get there information.

    0 讨论(0)
  • 2021-01-20 14:57

    You can look up the package name and many other parts of the AndroidManifest.xml by pulling the development tools from the emulator, and install it on the device with the requested applications. you can execute these commands at the command prompt to do this.

    while the emulator is connected, run:

    /path-to-android-sdk/platform-tools/adb pull /system/app/DevelopmentTools.apk

    disconnect the emulator, connect the device, and run:

    /path-to-android-sdk/platform-tools/adb install DevelopmentTools.apk

    0 讨论(0)
提交回复
热议问题