How to set system app is not disabled? - android

How can I set a system app (my custom system app) to be NOT DISABLED?
Just like the Launcher or Settings that the "Disable" button is not enabled. So the user can't disable my system app.
Below is the Launcher's effect:

It's not possible for a third party application (like yours) to define itself as not being possible to disable- It's important that the user be able to disable any application on their system. If you find a way, that will be considered a security flaw, and it'll likely be disabled in the next release of Android :)
Launcher and Settings are special cases in terms of not being possible to disable, since disabling those would make it difficult/impossible for the user to maintain their own device (or to undo their decision, since they wouldn't be able to launch the settings Activity and re-enable it).

Related

Programatically set NFC_PAYMENT_FOREGROUND setting for HCE in Android

I am trying to set priority for a payment card in a foreground activity, but setPreferedPaymentService() won't work until categoryAllowsForegroundPreference() returns true. However, this is tied to the "Foreground priority" (NFC_PAYMENT_FOREGROUND) system setting.
Has someone encountered a similar problem? How can I change that setting programmatically?
The whole point of the the setting "Foreground priority: Use payment app in foreground, even over default" (Settings.Secure.NFC_PAYMENT_FOREGROUND) is to give the device user an option to prevent apps from doing exactly this. Consequently, if there was a programmatic way to re-enable this option (after the user intentionally disabled it), having this option would be pointless.
Therefore, the answer is: You can't programmatically enable that system setting from your app.
However, what you can do is ask the user to reconsider their choice. You could do this, for instance, by sending a CardEmulation.ACTION_CHANGE_DEFAULT intent to let the user select your app as the default. Or you could navigate the user to the Tap & pay settings (using a Settings.ACTION_NFC_PAYMENT_SETTINGS intent).

How to disable, or hide system settings programmatically?

I do not want the user to open device settings, so I need to disable device settings.
I found way to open settings
startActivityForResult(new Intent(android.provider.Settings.ACTION_SETTINGS), 0);
But I am looking for a way to disable it, how can I do that?
You can not disable system packages unless you make a custom rom. Besides that it is a huge security risk to allow developers to disable settings so the user can not stop the app.
You may create custom launcher with kiosk mode to achieve your target. Note that this approach requires some actions from your users.
Related links
https://developer.android.com/work/cosu.html
http://pvolan.blogspot.ru/2017/01/android-50-kiosk-mode-aka-super.html

How to set my app as default home android?

I'm developing a Android application, and I would like that when it first starts it set itself as default action for Home button.
Currently this option is given to the user by the Android system only when he first press the Home button after running my app.
User don't want to click on check box as "Use by default for this action" it should be set by default my apps.
Thanks in advance.
This is not possible, and it is a good thing too.
Android allows users to choose their own defaults to prevent malicious apps from making themselves the default app to deal with an action, and hence protecting the user's data and device. If an app could set itself as the default homescreen or browser or call app etc. then it could steal the user's personal data and also potentially spoil or deny access to the device itself.
Due to the above reasons, this is not possible why the Android SDK, and I sincerely doubt that an unofficial means to do this exists.

Any listener for system preferences in Android

I want to capture event when an user try to go into the preferences screen, so I can ask password for it. The reason why I try this, I am developing app for the disabled. I don't want them to touch system settings directly, just the permitted helper.
Is there any event listener or receiver for this?
Thanks in advance.
I don't think there is anything in the public APIs that will allow you to do this. Device Admin is probably the closest thing, but I don't think it does this exactly.
If you wish to implement this (and be certain that it will be effective) you'd have to modify the OS slightly on your devices.
One possibility that might work and is within the APIs is to create a replacement home screen that does not show the usual items in the menu. If you were to go this route you could "lock" the into your activity and simply provide them no way to go to the settings except with a password or something. This would be a lot of work though, and would require the user to set your application as their default home screen. And even with this on the newer devices you may run into the trouble because there is a settings button inside the notification pull down, which I don't think there is a way to block, even with a replacement homescreen.

Android OS - Stop user from closing app or using any OS functionality

My team is trying to build an Android application for a tablet that will be dedicated for this sole purpose. One of the requirements is that the application is the only thing running on the device (at least from the user's point of view). The user should not be able to close it or use any other functionality from the OS (settings, other apps, etc.).
We have been doing some research and so far have not found anything. Is this we are trying to do even possible ? Does anybody have any idea how we could approach this ? Maybe blocking the buttons ?
Thanks,
It is possible but would be ugly in the long run without a custom built rom (http://xda-developers.com has instructions on how to do this), I wouldn't know where to start code wise - but there are a couple of applications which portray this kind of functionality - TodlerLock is one such app - its designed to stop todlers from from doing anything on the device, whilst the application keeps them entertained. It appears to intercept all button presses and acts as a home application to do this for the home button.
Then there are the programs like estrongs security manager that allows a user to set a password for some or all applications and basically stops the application being run without the password (it appears to intercept the intents and opens the security manager requesting the password first, if it fails it finishes the intent) - this maybe a much easier option to use something like this - you could set a password for most things, including settings and the security application itself, everything bar your application. This will stop the user doing anything you dont want them doing without the password.
You would have to set up the device for the user before hand though, as any home screen intercepter application can be changed but the user - so you would have to set the default, then lock access to the settings so the user can't change this action.
I think the only way of doing this to have your own custom version of Android built only for you. Get the android source, remove what ever you don't want and build it. I am not sure if you would ever want not to close it but you can make sure they can't install anything else on your ROM.
Im not sure about this, but, intercept the home intent and write your own custom home?
It sounds a lot simpler than writing your own custom rom.
This is not possible without OS changes. You cannot override the home button.

Categories

Resources