How to find the package name of default settings application?

Devu Soman picture Devu Soman · Apr 10, 2013 · Viewed 19k times · Source

I want to prevent launching of task manager and Settings applications in my application.For this,I tried to obtain currently running application and checked whether their package name is allowed or not .If it is not allowed then show a new activity.

When work out it is show that the package name of default android Settings application is com.android.settings.Now i have some doubts

  1. Is the Settings application has package name com.android.settings in all android versions?If not,which are they?

  2. How to find package name of Task Manager?

Answer

hoot picture hoot · Mar 28, 2017

try this

private String querySettingPkgName() {
        Intent intent = new Intent(android.provider.Settings.ACTION_SETTINGS);
        List<ResolveInfo> resolveInfos = getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
        if (resolveInfos == null || resolveInfos.size() == 0) {
            return "";
        }

        return resolveInfos.get(0).activityInfo.packageName;
    }