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).
Related
Sorry this will be a general question as I don't even know where to start.
What I want:
I have an app on androind (bonus if solution works on iOS) where the same app can present different views depending on if you are an end user or a technician. What I need is some SIMPLE method where the app at launch can read a variable. I have read a lot about shortcuts, Quick action, Environment variables, etc. etc. but I can't find anything that doesn't require as much programming as the app itself!
I can think of two approaches…
long press on Icon which gives the option to start in "advanced mode" by passing an argument to the app
some setting that can be read by the app at launch akin to an Environment variable in other OS
Can someone please send my in the right direction. Maybe there is a standard way of doing this I'm just not aware of?
Many thanks!
You could present the user with a dialog on first start. He can indicate his "role" either by choosing one, or by entering a password or enabling code.
Or, you can default the app behaviour to "user", and offer a menu option to "enable technician mode", which could then request a password or other code to enable this option.
Or, you can default the app behaviour to "user" and if the user performs a specific magic gesture (ie: swipe right, swipe left, swipe right) then the "technician" mode is enabled.
What I wanted to do is apparently not possible, so instead I worked around it by always starting the app in user mode and having a hidden button for techs. Of course a user could find it by mistake but if security becomes an issue I will have to add a tech login. For now this solution is acceptable.
It did require some rework to get the sequence right but it turned out to be the lesser evil.
I am getting problem in my app .where i need to mark the particular Settings I have used the following code:
startActivity(new Intent(android.provider.Settings.ACTION_WIRELESS_SETTINGS));
Its open the setting page but it does not mark the particular Entities.How could i get the automark option Could anybody help me out!!#Thanks
this is not possible, unless you have the rights and access the setting directly (not with an intent, but with the Settings class), and even though, I'm not sure you can.
What you can do is what google maps does. When your app starts, check if the gps is enabled, if it is not, display an alert notifying the user, with a button to quit the app, and a button to go to the settings screen. When the user comes back from Settings screen, test again.
If the action that you are trying to do was allowed then users would be very mad if some application would turn on their wireless connection or even worse the GPS sensor.
This change is available to change only by the user him self. So as mentioned the most you can do in case you need Internet connection or GPS sensor available is to present a user with the relevant message and fire an intent that will take them to the settings screen to change this setting them self.
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).
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.
I am developing an application where I have to change the screen lock password on a button click,can anybody tell me how can I do this.
If you are talking about the unlock pass word set in the device settings by the user then the answer is you can't.
If an application could change the unlock password/pattern without user interaction then these security features would be mostly useless. A rogue application could in theory lock the user out of their own device if this were possible.
Edit: if your aim is not to change this value without interaction but just to send them to the correct settings page. You might be able to do that some how. You'd want to look into what intents you can use to start the Settings Activities. But if you are developing this application for use by the general public I would strongly recommend you rethink having try to do anything with the users security settings. As a user if an application prompted and then sent me to the security settings page with the intention of having me change something in there I would immediately uninstall it.
Edit 2: I've never seen it until just now so I don't know for sure what they used to achieve that. Since it states that must be android 2.2+ though I would assume they are using the Device Administration APIs The docs seem to indicate that it can "Prompt user to set a new password." Which I would think means that it is just going to start the settings activity for them. It is not actually changing the password value by itself. This whole API is subject to user activation also. So even if you get installed on a device the user must explicitly "activate" your app before it is able to make use of any of the admin APIs
I am sure the only way this is possible is if you signed your APK with the device key. This way it could access API's that are limited to system applications. This isn't possible for a normal app, only one that is baked into a custom ROM or device manufacturer ROM when building Android from source.
I do not exactly understand what you are trying to do. If you wish to change the lock screen password programmatically, and your'e application is A device administration than you can call:
resetPassword method of DevicePolicyManager like this for example:
m_policyManager.resetPassword("bla bla", DevicePolicyManager.PASSWORD_QUALITY_SOMETHING);