Sukesh
Sukesh

Reputation: 323

Android Custom Launcher Application

I am working on a custom launcher application. I want to get information like "How many cameras, message or browser applications are installed on my device", that can be default or third party application? Please suggest me if have any idea for this.

Thanks in advance

Upvotes: 0

Views: 826

Answers (2)

Aleks G
Aleks G

Reputation: 57316

To get the info you're after, you'll need to use PackageManager class and whatever else it provides. For example, the following code retrieves the list of available "applications", that is Activities that are defined with Launch Intent in their respective AndroidManifest files - together with the .app files that contain them, launcher labels and icons, etc.

PackageManager pm = getPackageManager();
Intent intent = new Intent(Intent.ACTION_MAIN, null);
String _label, _class, _src;
Drawable _icon;

for (ResolveInfo rInfo : pm.queryIntentActivities(intent, PackageManager.PERMISSION_GRANTED)) {
    if (pm.getLaunchIntentForPackage(rInfo.activityInfo.packageName) == null) {
        continue;
    }
    _class = rInfo.activityInfo.packageName;
    _label = rInfo.activityInfo.loadLabel(pm).toString();
    _src = rInfo.activityInfo.applicationInfo.sourceDir;
    _icon = rInfo.activityInfo.loadIcon(pm);

    Log.d("PackageList", "label: " + _label + ", package: " + _class + ", sourceDir: " + _src + ", icon: " + (_icon == null ? "blank" : "present"));
}

Upvotes: 0

CommonsWare
CommonsWare

Reputation: 1006704

You can use PackageManager to find out about the installed applications. However, you have no reliable way to determine which of those are "cameras" or "message" or "Browser".

Upvotes: 3

Related Questions