Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show icon of apk in my File manager

Tags:

android

apk

icons

I want to show icon of apk file in my listview.

How can i get icon of apk?

like image 343
Nam Vu Avatar asked Apr 15 '11 09:04

Nam Vu


People also ask

Where is the app icon in APK?

the icons would be in the drawable-hdpi folder. just in case you were asking where the . apk files are, look in /data/app or /system/app, depending on the app.

Where can I find APK folder?

Finding APK Files If you want to locate the APK files in your Android phones, you can find the APK for user-installed apps under /data/app/directory while the preinstalled ones are located in /system/app folder and you can access them by using ES File Explorer.

How do I find hidden APK files?

Find Hidden Apps Through Your File Manager So, tap the relevant file manager icon to open a list of categories and tools. Go into Apps and you'll see all the programs installed on your device, as well as any Android Package Kits (APK). You can manage each item from here, too, from sharing to uninstalling it.


1 Answers

    if (file.getPath().endsWith(".apk")) {
        String filePath = file.getPath();
        PackageInfo packageInfo = context.getPackageManager().getPackageArchiveInfo(filePath, PackageManager.GET_ACTIVITIES);
        if(packageInfo != null) {
            ApplicationInfo appInfo = packageInfo.applicationInfo;
            if (Build.VERSION.SDK_INT >= 8) {
                appInfo.sourceDir = filePath;
                appInfo.publicSourceDir = filePath;
            }
            Drawable icon = appInfo.loadIcon(context.getPackageManager());
            bmpIcon = ((BitmapDrawable) icon).getBitmap();
        }
    }

The most important line is appInfo.publicSourceDir = filePath;

This is a bug. See http://code.google.com/p/android/issues/detail?id=9151

The null check packageInfo != null is there in case the .apk is not parsed correctly.

like image 52
NkD Avatar answered Oct 16 '22 05:10

NkD