Reputation: 175
I've a bit of a problem that I need help with. We are making a device on which we need to limit a user from doing a lot of things. So we have investigated making a custom launcher to hide certain apps and features from being displayed.
But one thing we also need to do is to limit what the user can set from the settings menu/app in android. It looks like the only way to change what is visible/accessible in this app/menu is through writing our own custom ROM, which we do not want to do.
So what I want to know is,can I write a new setting app in android to replace the default one?
Thanks in advance, Wihan
Upvotes: 2
Views: 3489
Reputation: 11
I have done this using Device owner. First declare in your manifest an activity with intent filter
<!-- Default Activity Intent for Settings App -->
<activity
android:name=".ui.DeviceSettings"
android:label="@string/settings_label">
<intent-filter>
<action android:name="android.settings.SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
Then using Device Policy Manager setPersistentPreferredActivity
val DEFAULT_ANDROID_SETTINGS_INTENT = IntentFilter(ACTION_SETTINGS).apply {
addCategory(Intent.CATEGORY_DEFAULT)
}
val settingsComponentName = ComponentName(
packageName,
settingsActivity
)
devicePolicyManager.addPersistentPreferredActivity(
componentName,
DEFAULT_ANDROID_SETTINGS_INTENT,
settingsComponentName
)
To complete this setup, you must disable default Settings App of the device (the package can vary per OEM), hide the app using
devicePolicyManager.setApplicationHidden(componentName,"com.android.settings",true)
Upvotes: 1
Reputation: 1877
If you only want to restrict user from changing settings you can make your app act like another Settings application by adding next line to your manifest
<action android:name="android.settings.SETTINGS" />
For example if you are making a launcher app this is what your activity in manifest should like like if you want to make it both the settings and launcher activity.
<activity
android:name=".ExampleActivity"
android:label="@string/app_name"
android:launchMode="singleTask"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.settings.SETTINGS" />
</intent-filter>
</activity>
Upvotes: 0
Reputation: 15775
The short answer is, no. The settings app is bundled with the ROM and is a privileged app which has access to protected settings as well as hidden APIs. You could attempt to create your own, but it would have to be signed with the platform key used to sign the other internal components of the ROM and also built against some if the internal (non-SDK) APIs.
Upvotes: 1