9
votes

L'application installée est tierce partie ou non

Comment puis-je obtenir la liste des applications tiers installées sur le téléphone Android.

Je suis capable d'obtenir la liste d'application avec le code ci-dessous, mais je ne veux que des applications tierces. P>

PackageManager pm = context.getPackageManager();
appInstalModel.setAppName(p.applicationInfo.loadLabel(context.getPackageManager()).toString());
appInstalModel.setAppPkg(p.packageName);
appInstalModel.setAppVersionName(p.versionName);


2 commentaires

Qu'entendez-vous par tiers? Pas de Google? Pas de toi?


@ROFLCOPTR installé sur le système ou installé par l'utilisateur.


5 Réponses :


2
votes

Le L'objet ApplicationInfo aura le Flag_system Drapeau non défini. Le Le programme SDMOVE peut avoir un exemple de code.


2 commentaires

parfait. Je dois m'y regarder.


Comment puis-je cloner le projet SDMOVE?



7
votes
    List<ApplicationInfo> apps = getPackageManager().getInstalledApplications(0);
    for (int i=0; i < apps.size(); i++)
    {
        if ((apps.get(i).flags & ApplicationInfo.FLAG_SYSTEM) == 1)
        {
            //System app
       }
    }

1 commentaires

Je pense que ça devrait aimer ça. Si ((apps.get (i) .ApplicationInfo.Flags & ApplicationInfo.Flag_System) == 1) {// app}



2
votes

petits changements dans la réponse @roflcoptr. XXX

Merci à @ROflCopTR pour votre réponse.


1 commentaires

Je recommande fortement de changer cela depuis (xxx et applicationinfo.flag_system) == 1) à (xxx et applicationinfo.flag_system)! = 0) ou (xxx & ApplicationInfo.Flag_System == ApplicationInfo.Flag_System) . Le 1 fonctionne uniquement car Flag_System se trouve être 1, mais c'est une valeur codée en dur.



7
votes

La réponse de ROFLCOPTRException est correcte. Mais dans certains cas, cela ne vous donnera pas toutes les applications tiers installées. ApplicationInfo code> a aussi un drapeau flag_updated_system_app code> qui est défini

Si cette application a été installée comme mise à jour vers un système intégré Application p> blockQuote>

sur mon téléphone intelligent, de telles applications incluent Amazone Kindle, Adobe Reader, Slacker Radio et d'autres personnes. Ces applications ne sont pas venues avec le téléphone et ont été installées à partir de Google Play Store. Ainsi, ils peuvent être considérés comme des applications tierces. P>

Donc, vous pouvez également vérifier flag_updated_system_app code> drapeau. P>

final PackageManager packageManager = _context.getPackageManager();
List<ApplicationInfo> installedApplications = 
    packageManager.getInstalledApplications(PackageManager.GET_META_DATA);

for (ApplicationInfo appInfo : installedApplications)
{
    if ((appInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0)
    {
        // IS A SYSTEM APP
    }

    if ((appInfo.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0)
    {
        // APP WAS INSTALL AS AN UPDATE TO A BUILD-IN SYSTEM APP
    }
}


0 commentaires

0
votes
public static List<PackageInfo> getInstalledAppList(Context context) {
        ArrayList<PackageInfo> packList = (ArrayList<PackageInfo>) context.getPackageManager().getInstalledPackages(0);
        showLog("/n/n ********************** App List ********************");
        for (int i = 0; i < packList.size(); i++) {

            PackageInfo packInfo = packList.get(i);
            if ((packInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
                String appName = packInfo.applicationInfo.loadLabel(context.getPackageManager()).toString();
                showLog(appName + "(" + packInfo.packageName + ")");
            } else {
                packList.remove(i);
                i--;
            }
        }

        showLog("List Size : " + packList.size());
        showLog("/n/n ********************** END ********************");
        return packList;
    }

0 commentaires