마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

구글플레이 등록된 앱으로부터 APK 다운로드

0 추천
구글플레이의 앱이 등록된 URL 이나 Package Name 으로 APK 를 얻을수 있는 방법이 있는지 궁금합니다.

관련자료를 못찾겠어서 질문드립니다..답변부탁드려요 ㅠ
늘순수하게 (360 포인트) 님이 2016년 4월 19일 질문

1개의 답변

0 추천
구글 스토어에서 apk extractor 라고 검색하면 많이 나옵니다.
aucd29 (218,390 포인트) 님이 2016년 4월 19일 답변
혹시 안드로이드 소스코드(자바)로 하는방법은 없을까요!?
/*
 * AppList.java
 * Copyright 2013 Burke Choi All rights reserved.
 *             http://www.sarangnamu.net
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package net.sarangnamu.apk_extractor;

import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.WeakHashMap;

import net.sarangnamu.apk_extractor.cfg.Cfg;
import net.sarangnamu.common.BkMath;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.graphics.drawable.Drawable;

public class AppList {
    private static AppList mInst;
    private WeakHashMap<String, Drawable> mIconMap;

    public static AppList getInstance() {
        if (mInst == null) {
            mInst = new AppList();
        }

        return mInst;
    }

    private AppList() {

    }

    public ArrayList<PkgInfo> getInstalledApps(Context context, String sortBy) {
        return getAllApps(context, true, sortBy);
    }

    public ArrayList<PkgInfo> getAllApps(Context context, boolean hideSystemApp, String sortBy) {
        ArrayList<PkgInfo> res = new ArrayList<PkgInfo>();
        List<PackageInfo> packs = context.getPackageManager().getInstalledPackages(0);

        if (mIconMap == null) {
            mIconMap = new WeakHashMap<String, Drawable>();
        }

        for (int i = 0; i < packs.size(); i++) {
            PackageInfo p = packs.get(i);
            if (hideSystemApp) {
                if ((p.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
                    continue;
                }
            }

            PkgInfo newInfo = new PkgInfo();
            newInfo.appName = p.applicationInfo.loadLabel(context.getPackageManager()).toString();
            newInfo.pkgName = p.packageName;
            newInfo.versionName = p.versionName;
            newInfo.versionCode = p.versionCode;

            if (!mIconMap.containsKey(p.packageName)) {
                mIconMap.put(p.packageName, p.applicationInfo.loadIcon(context.getPackageManager()).getConstantState().newDrawable());
            }

            newInfo.icon = mIconMap.get(p.packageName);
            newInfo.srcDir = p.applicationInfo.sourceDir;
            newInfo.size = new File(p.applicationInfo.sourceDir).length();
            newInfo.appSize = BkMath.toFileSizeString(newInfo.size);
            newInfo.firstInstallTime = p.firstInstallTime;

            res.add(newInfo);
        }

        if (sortBy.equals(Cfg.SORT_ALPHABET_ASC)) {
            Collections.sort(res, new SortByAlphabetAsc());
        } else if (sortBy.equals(Cfg.SORT_ALPHABET_DESC)) {
            Collections.sort(res, new SortByAlphabetDesc());
        } else if (sortBy.equals(Cfg.SORT_FIRST_INSTALL_TIME)) {
            Collections.sort(res, new SortByFirstInstallTime());
        } else if (sortBy.equals(Cfg.SORT_LAST_INSTALL_TIME)) {
            Collections.sort(res, new SortByLastInstallTime());
        }

        return res;
    }

    ////////////////////////////////////////////////////////////////////////////////////
    //
    // Comparator
    //
    ////////////////////////////////////////////////////////////////////////////////////

    class SortByFirstInstallTime implements Comparator<PkgInfo> {
        @Override
        public int compare(PkgInfo lhs, PkgInfo rhs) {
            if (lhs.firstInstallTime > rhs.firstInstallTime) {
                return 1;
            } else if (lhs.firstInstallTime < rhs.firstInstallTime) {
                return -1;
            }

            return 0;
        }
    }
    
    class SortByLastInstallTime implements Comparator<PkgInfo> {
        @Override
        public int compare(PkgInfo lhs, PkgInfo rhs) {
            if (lhs.firstInstallTime < rhs.firstInstallTime) {
                return 1;
            } else if (lhs.firstInstallTime > rhs.firstInstallTime) {
                return -1;
            }

            return 0;
        }
    }

    class SortByAlphabetAsc implements Comparator<PkgInfo> {
        @Override
        public int compare(PkgInfo lhs, PkgInfo rhs) {
            return lhs.appName.compareTo(rhs.appName);
        }
    }
    
    class SortByAlphabetDesc implements Comparator<PkgInfo> {
        @Override
        public int compare(PkgInfo lhs, PkgInfo rhs) {
            return rhs.appName.compareTo(lhs.appName);
        }
    }

    ////////////////////////////////////////////////////////////////////////////////////
    //
    // PkgInfo
    //
    ////////////////////////////////////////////////////////////////////////////////////

    public static class PkgInfo {
        public String appName;
        public String pkgName;
        public String versionName;
        public String appSize;
        public String srcDir;
        public int versionCode = 0;
        public long size;
        public Drawable icon;
        public long firstInstallTime = 0;
    }
}
newInfo.srcDir = p.applicationInfo.sourceDir; 이게 apk 파일 경로이니 해당 경로에서 원하는 경로로 파일을 복사 하면 됩니다.
...