I'm designing an app which uses wifi for certain purposes. I want to prevent the user from turning the wifi radio off from the wifi settings of the device while my application is running and the device connected to my wifi network. Is there a chance this can be done? I read in WifiManager.WifiLock and they say this: "Note that WifiLocks cannot override the user-level "Wi-Fi Enabled" setting, nor Airplane Mode. They simply keep the radio from turning off when Wi-Fi is already on but the device is idle." Can it be done somehow??
You cannot prevent the user from turning off the wifi from your code. Even if you find out an evil way to do it , you should not try to do it. If I find out any app in my phone does evil things like these, I will just remove the app. I am sure most people are just like me.
If you really want to do it for some reason , perhaps you could tell us what the scenario is and we might be able to help you with a different solution you havent thought about
Related
I want to use my device like a camera in my house, and i want to enable/disable it times to times through Wi-Fi when needed! How can i do that? I know that when device in sleep mode, t disables wifi, but maybe there is some another feature to disable screen or something else.
I didnt tried it so far but you would need to change Android-settings to let wifi turned on while the device is in sleep mode. So you have a connection running. Then you should create a background-service with a callback function. Everything what you need should be described here.
https://developer.android.com/training/best-background.html
I would like to create Android background service application that prevents to shut down the 3G connection.
I will try to explain better, I've 4 Android tablets, and I need that my employees do not turn off the 3G connection.
Someone have an examples?
thanks beforehand
The only reason why a mobile data connection will shut down is because either:
The user turned on airplane mode, or
The user fussed around in Settings and screwed up an access point name or something
You cannot control either of these behaviors from an ordinary SDK app, except perhaps on a rooted device.
I am developing an application. In which, I want to disable the using Internet for some time, especially if he has homework. How can I disable the Internet ?
To enable/disable data connection programatically check this post
To disable / enable wi-fi refer this tutorial
You can set the "mobile data" and "wifi state" whithin your application as long as you have the right permissions.
Also, you can register system wide BroadcastListener to detect when the device is connected to the internet, and do whatever you consider needs to be done.
There are ways to do this using Airplane mode, or via system hooks but the user will still retain the power to connect back. If you disconnect it again, he can disable/remove your app.
Is there an absolute way to restrict the user? I don't believe so. For security reasons alone, Providing this ability to third party applications would be very dangerous.
I found a lot of posts where people say you can't manage 3G/2G connection switch, but we all have widgets and such and I wanted to know if there is A way (even a console command) that would let my app automatically enable 2G connection, or a shortcut or just anything, because I'd need to disable 3G connection and let the user reactivate it. Is it possible in any way? I don't mind if a rooted phone is required :)
I know there isn't such an API, but there shall be a way in which widgets can work, and I'd love to know it :)
I need a fix for this strange problem appearing in android. Sometimes I notice that even I have full cellular network, data network is lost.(Not able to connect to internet although have all set properly). This possibly occurs after I leave wifi. A quick fix to make it working is toggle 2G/3G option in settings --> Mobile Networks, which probably clears the network stack and makes it all working.
But for my application, which requires always to be connected to internet, I need a fix programatically. I cannot toggle that from code ? Or can I ?
I read and tried a fix by rewriting APN settings, but that do not solve the issue entirely, as we move out from wifi connectivity.
Do anyone have any fix for this from code ?
Because of the way Android networking and security work, there's no way to toggle 2G/3G-4G without going into settings. Some "rooted" phones were once able to do this, but that was disabled in 2.1 and higher.
There's no solution for this programatically. You need to toggle the network option which normally cannot be done without user intervention.