3

ユーザーがインストールしたアプリとシステム アプリを区別するために、次のコードを使用しています。

final PackageManager pm = getPackageManager();
List<ApplicationInfo> packages = pm.getInstalledApplications(PackageManager.GET_META_DATA);
for (ApplicationInfo packageInfo : packages)
{
    if ((packageInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0)
        Log.d(TAG, "Installed package (System) :" + packageInfo.packageName);
    else
        Log.d(TAG, "Installed package (User) :" + packageInfo.packageName);
}

これにより、実際にはそうではないユーザーがインストールしたアプリとして一部のアプリが提供されます。以下は、エミュレーターの LogCat です。

Installed package (User) :com.android.smoketest
Installed package (User) :com.android.widgetpreview
Installed package (User) :com.example.android.livecubes
Installed package (User) :com.example.android.apis
Installed package (User) :com.android.gesture.builder
Installed package (User) :com.example.android.softkeyboard
Installed package (User) :com.android.smoketest.tests
Installed package (User) :faheem.start

理想的には、最後のアプリケーションのみが User Installed Apps に出力される必要があります。

4

1 に答える 1