Is it somehow possible to set Android to standby-mode programmatically ?
If you're developing your own ROM or you have a rooted phone (it's need to be checked which user is able to do this) then you should have a look to the PowerManager.goToSleep functionality. Here is a discussion about this function in the Google Groups. And here you can read about this particular permission.
http://developer.android.com/reference/android/os/PowerManager.html#goToSleep%28long%29
This is what i think you are looking for.
Don't forget to include following permission.
android.permission.DEVICE_POWER
This functionality has been removed since API level 21: https://developer.android.com/sdk/api_diff/21/changes/android.os.PowerManager.html
Like Yury also mentioned, before you were able to call powerManager.goToSleep(time), but you would have needed a rooted device or app would have needed to be signed as a system app to acquire the relevant rights.
Related
I disabled the camera of a Samsung S20 in android 12 through the method
DevicePolicyManager.setCameraDisabled(ComponentName admin, boolean disabled).
I want to disable NFC using policies found in DevicePolicyManager, but i have yet to find a method for disabling NFC. Does anyone know if there even exists a method to do this? Is there another way to enforce a toggle/disable NFC through policies?
Apparantly there is no straightforward way to disable NFC by means of DevicePolicies according to the official documentation.
There are some options that include the term NFC but it seems it's mostly related to provisioning.
Most answers or documentation suggests to disable NFC by accessing the Adapter programmatically (see linked answer;which is not what you asked for).
In addition, most answers emphasize that the approach is not applicable to "normal" devies. It requires root access to disable the adapter. That may be a limiting for you as well.
For what it's worth, a custom device policy could be a promising lead. I'd advise to research that option.
Alternatively, if you can you could inform the user that NFC has to be turned off upon App start and quit otherwise.
I have an security App (App Locker) that uses this permission:
android.permission.GET_TASKS
In android Lollipop this permission is deprecated and i want that my app works in +21 API.
Can anyone guide me how?
Thnx :)
There is reason why it is deprecated.
The protection Level of android.permission.GET_TASKS has been elevated to signatureOrSystem.
There is no easy and unharmful solution for that.
As of LOLLIPOP, this method is no longer available to third party applications: the introduction of document-centric recents means it can leak personal information to the caller. For backwards compatibility, it will still return a small subset of its data: at least the caller's own tasks (though see getAppTasks() for the correct supported way to retrieve that information), and possibly some other tasks such as home that are known to not be sensitive.
http://developer.android.com/reference/android/app/ActivityManager.html#getRecentTasks(int,%20int)
I saw a new permission REAL_GET_TASKS that is said to be used instead of GET_TASKS:
New version of GET_TASKS that apps can request, since GET_TASKS doesn't really give access to task information. We need this new one because there are many existing apps that use add libraries and such that have validation code to ensure the app has requested the GET_TASKS permission by seeing if it has been granted the permission... if it hasn't, it kills the app
with a message about being upset. So we need to have it continue to look like the app is getting that permission, even though it will never be checked, and new privileged apps can now request this one for real access.
See the Android code difference at: https://android.googlesource.com/platform/frameworks/base/+/2d7576b%5E!/
I would like to write an application which can programatically generate touch events on the phone.
I have already tried this methods:
adb : adb swipe and so on... It requires USB cable and connect the phone to pc
adb ON TCPIP: same
My problem with adb is to require so much presetting by user and I don't want to make the user to learn it. I have already made an application which use adb, but it's difficult for the user to set up properly :(
I have heard and I tried to sign my application with platform sign, but it's not good for me, because I would like to publish my app on android market and it is not a system application...
I would like to find a way to achieve this in a single application which can produce touch outside of the app (from background) and I would like to publish on market.
I have found this application: https://play.google.com/store/apps/details?id=com.teamviewer.quicksupport.samsung which can basically do this. Because when I click on my computer, it send a message to the phone and the phone make the touch on the screen. How and with what privileges can teamviewer do it?
Please give me some advice about it.
I would like to find a way to achieve this in a single application which can produce touch outside of the app (from background) and I would like to publish on market.
This is not possible, outside of what little input faking can be done by an accessibility service.
How and with what privileges can teamviewer do it?
If your read that Play Store listing, you will notice that it only works with Samsung devices. That is because the makers of TeamViewer struck a deal with Samsung to enable this sort of integration. Similarly, the TeamViewer team struck deals with a few other device manufacturers. However, they did not do so with all manufacturers, and so TeamViewer does not work on all devices.
Have a look here .This might be useful.
InputInjector
Android library that eases the process of injecting InputEvents (MotionEvent, KeyEvent) to you Android app. The library uses internal API calls to inject events and depend on the accessability of these. This library will therefore not work on all devices but theoretically support Android 2.3 and forward (API level 9-18+).
Androd 2.3 (API level 9-15)
In older versions of Android we envoke the same system calls as used by the Instrumentation framework.
Permission No special permission needs to be set.
Androd 4.1.2 (API level 16 and forward)
As of API level 16 we have access to the InputManager class. We use this as the basis for the input injection.
Permission Using InputManager for injection requires setting permission android.permission.INJECT_EVENTS in your manifest.
Using this permission may require altering Lint Error Checking in order to be able to compile. In Eclipse this is done by going to Window->Preferences->Android->Lint Error Checking and then finding ProtectedPermissions and setting severity to something else than error.
NOTE: In order to inject events to other apps using InputManager, your apk must be signed with system level certificate.
https://github.com/arnebp/android-inputinjector
I want to add my app's shortcut on phone's lock screen, is it possible in android ? Below screenshot (which is of iPhone) will make it clear.
Without Widget..
Any help will be appreciated, thanks :)
If you want to add a shortcut in the home-screen then that is obviously possible with the API Android provides.
But you are talking about adding a shortcut to the lock-screen, which only a few (very few) Android devices support officially. I have experience with a lot of different Android devices from a lot of different manufacturers but none of them supports adding an app shortcut on the lockscreen.
You might not be willing to accept my answer as may not provide the answer you were looking for, but still I would try to give you two possible solutions :-
1) You need to create your own lockscreen for this and then you obviously have the privilege of adding any shortcut you want there. See if that's a possible solution for you.
2) Or, if know of any Android device that does support this, then you need to contact the device manufacturer for knowing the API.
I am rest assured there is no official API available to put an app shortcut on the lockscreen.
Hope I could help you with my best.
Check out this article at: http://fieldguide.gizmodo.com/put-your-key-apps-on-the-android-lock-screen-for-easy-a-1621573474. Following these steps should get you what you are looking for.
I want to make a security app for Android phones. Basically, I don't want anyone to be able to un-install it without having to enter a specific password first.
Also, is there a way to prevent the app from being stopped manually (like being closed via. Taskmanager) etc?
This sounds more akin to Malware-like behaviour than that of a regular Android application, anyway:
For a regular Android application, I'd imagine that making it 'uninstallable' is near enough impossible to achieve - try to contemplate what the state of the Android app market would be like right now if this were possible!
On the other hand, if privileged control (root access) was available then this might be a possibility - an example of that could be like how wireless carriers implement bundled software. However, like I mentioned, there is no regular avenue available for applications released via. the Android market to achieve what you've asked, it should be pretty clear to you why...