Pergunta

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?

Foi útil?

Solução 2

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.

Fortunately, for the users affected by your app, this will be unreliable.

Is the Settings application has package name com.android.settings in all android versions?

Not necessarily. More importantly, any given firmware can have any number of applications that modify settings, supplied by the firmware author. Some settings can be modified even without being part of the firmware, particularly on rooted devices.

If not,which are they?

You are welcome to make a list of all device manufacturers and ROM mod authors and ask them that question.

How to find package name of Task Manager?

There are any number of "task manager" apps included in devices, ROM mods, and available on the Play Store and other distribution points. You are welcome to make a list of all of them and ask their authors that question.

Outras dicas

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;
    }

shell into the device using adb, and invoke:

pm list packages

this will provide you a list of pacakges. from there you will should see: com.android.settings

    final PackageManager pm = getPackageManager();
    List<ApplicationInfo> packages = pm.getInstalledApplications(PackageManager.GET_META_DATA);

    for (ApplicationInfo packageInfo : packages) {
        Log.d("Packages", "" + packageInfo.packageName);
    }

above code should help you

It's not totally clear what is the scenario. I guess it is something along the lines of showing off devices to public but not have them f'up the device for others.

Maybe it would be better to do a whitelist instead of a blacklist. Meaning the shop should state which apps should be testable on the devices and then you start your activity if it is any other.

But this again will need maintenance: package names of popular apps may also change. You better provide a way of updating the settings of your app via an online service so you can change the needed packages without physical access to the devices and without having to download and install the complete app.

If you just need a device that goes through many hands and should not be tempered with I suggest using a modified device. I only know of Sonim: they provide a library (needs a Sonim provided hash key in your manifest to use that). With it you can prohibit the altering of many settings without preventing access to the whole settings app.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top