Link

https://tw.voicetube.com/videos/68590?ref=new

文章標籤

HowHow 發表在 痞客邦 留言(0) 人氣()

Link

https://tw.voicetube.com/videos/69743?ref=new

文章標籤

HowHow 發表在 痞客邦 留言(0) 人氣()

Link

https://tw.voicetube.com/videos/70966?ref=new

文章標籤

HowHow 發表在 痞客邦 留言(0) 人氣()

Link:

https://tw.voicetube.com/videos/49446?ref=vt_web_recommended_video_list

文章標籤

HowHow 發表在 痞客邦 留言(0) 人氣()

- Link:

    https://tw.voicetube.com/videos/20454?ref=toeic

文章標籤

HowHow 發表在 痞客邦 留言(0) 人氣()

link:

https://tw.voicetube.com/videos/18348?ref=toeic

文章標籤

HowHow 發表在 痞客邦 留言(0) 人氣()

link:

https://tw.voicetube.com/videos/14476?ref=toeic

文章標籤

HowHow 發表在 痞客邦 留言(0) 人氣()

link:

https://tw.voicetube.com/videos/54542?ref=new

文章標籤

HowHow 發表在 痞客邦 留言(0) 人氣()

    public static Bitmap getApkIcon(Context context, String path) {
        Bitmap icon = null;
        PackageManager pm = context.getPackageManager();
        PackageInfo packageInfo = pm.getPackageArchiveInfo(path, 0);
        // if the apk file is broken, then packageInfo will be null
        if (packageInfo == null) {
            return null;
        }
        ApplicationInfo appInfo = packageInfo.applicationInfo;
        //icon = pm.getApplicationLogo(appInfo);

        AssetManager assetMgr = reflectionApis.getAssetManagerWithPath(path); // 拿到別的APK的AssetManager
        if (null != assetMgr) {
            Resources r = context.getResources(); // 取得一個實作Resource介面的實例後,可使用getFile()、getInputStream()等方式來操作或取得資源檔案的相關資源
            Resources res = new Resources(assetMgr, r.getDisplayMetrics(), r.getConfiguration());
            if (appInfo.icon > 0) {
                Drawable drawable = ResourcesCompat.getDrawable(res, appInfo.icon, context.getTheme()); // 從appInfo中要icon並套用目前主題
                if (drawable instanceof BitmapDrawable) { // 若是BitmapDrawable,直接getBitmap
                    icon = ((BitmapDrawable) drawable).getBitmap();
                } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
                        && drawable instanceof AdaptiveIconDrawable) {// 先判斷是否為8.0後版本,以免前面版本不認得AdaptiveIconDrawable造成Crash
                                                                         drawable為切成圓形的adaptive icon,若要自己切形狀則用layerDrawable疊起來在處理
                    int width = drawable.getIntrinsicWidth(); 
                    int height = drawable.getIntrinsicHeight();
                    icon = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);

                    Canvas canvas = new Canvas(icon);
                    drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
                    drawable.draw(canvas);
                } else {
                    icon = BitmapFactory.decodeResource(res, appInfo.icon);
                }
            }
            assetMgr.close();
        }
        return icon;
    }
}

getIntrinsicWidth用途:

http://lp43.blogspot.tw/2012/03/android.html

HowHow 發表在 痞客邦 留言(0) 人氣()

Link:

https://tw.voicetube.com/videos/59676?ref=new

HowHow 發表在 痞客邦 留言(0) 人氣()

1 23