1

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 ?

jaudo
  • 83
  • 1
  • 7
  • 15
    best S/O question title ever. – HorseloverFat Jan 17 '13 at 14:48
  • Think carefully about something like this. If your goal is to prevent cheating, or distractions, it's trivial to have a second phone/etc. Do you *really* need to disable the internet connection? – Alex Feinman Jan 17 '13 at 14:49
  • Airplane mode disables the internet. http://stackoverflow.com/questions/3249245/how-to-set-the-airplane-mode-on-to-true-or-on – Michael Celey Jan 17 '13 at 14:50
  • 1
    Note that airplane mode cannot be changed on Android 4.2+ from a normal SDK application. Only ones signed by the firmware signing key or are installed on the system partition can hold the requisite permission. – CommonsWare Jan 17 '13 at 14:53
  • @CommonsWare really can you post a blog about "how to sign by the firmware signing key". I do not understand how I can do that ? I have read but I do not get what I should do. Can you explain step by step ? – jaudo Jan 17 '13 at 15:11
  • "I do not understand how I can do that ?" -- you start by building your own ROM mod. – CommonsWare Jan 17 '13 at 15:30
  • I should change the ROM file. Am I understand right ? – jaudo Jan 17 '13 at 15:33
  • why would you want to disable the internet ? – njzk2 Jan 17 '13 at 15:34
  • @njzk2 Why this site refuses to do other peoples homeworks ? The reason is same ( nearly ) – jaudo Jan 17 '13 at 15:35
  • i don't understand. (but that's ok, i don't have another answer to give anyway) – njzk2 Jan 17 '13 at 15:41

3 Answers3

1

To enable/disable data connection programatically check this post

To disable / enable wi-fi refer this tutorial

Community
  • 1
  • 1
Abhishek Sabbarwal
  • 3,758
  • 1
  • 26
  • 41
  • Are there a way to disable the application to be used ? – jaudo Jan 17 '13 at 15:05
  • I mean I will disable the application. If he click on, system will refuse to open it. – jaudo Jan 17 '13 at 15:36
  • I dont think that will be possible until you yourself manually lock the settings application in android. One thing you could do is down load the app called "App lock" and lock your setting with it altogether. SO only you know the passcode to open the settings and make whatever changes you want. – Abhishek Sabbarwal Jan 17 '13 at 15:40
0

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.

Robert Estivill
  • 12,369
  • 8
  • 43
  • 64
  • How can I listen BroadcastListener then detect the device is trying to connect to the Internet ? – jaudo Jan 17 '13 at 15:02
  • can you give sample code ? Should I put something on – jaudo Jan 17 '13 at 15:37
  • Get notify when internet becomes available http://stackoverflow.com/questions/3125284/how-can-we-get-notified-if-the-phone-has-got-internet-access Toggle wifi http://stackoverflow.com/questions/5766518/can-wifi-be-turned-off-programatically Toggle 3g http://stackoverflow.com/questions/12535101/how-can-i-turn-off-3g-data-programmatically-on-android – Robert Estivill Jan 17 '13 at 17:24
0

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.

Anup Cowkur
  • 20,443
  • 6
  • 51
  • 84