Restrict Android Device Wifi Connection‏ - android

How to force android to connect specifically defined wireless network
Is it possible?
User should able to connect defined work wi-fi or wifis,
but should not access any other networks like home.

Firstly for what you want to do that?For your application or the device?
If it's your application you can do restrictions about connection type and network etc.
But if you are talking about the device you cant achieve something like that unless you have the control of the whole system which is not possible.

One option would be to create an app or service that would pick up the:
NETWORK_STATE_CHANGED_ACTION Intent
And then in turn use the
WifiManager.getConnectionInfo()
to check whether this is a legitimate network, if not then just disconnect and notify the user.

Related

Connect to specific network SSID (hotspot) when app active

Before I start this journey in Android I want to know if it is possible to connect to a specific network SSID when an app is active and restore the previous network settings when exit the app or when the device go sleep.
The reason I want to this:
An app for a specific device that can be reachable via adhoc
connection;
No need to hook into an existing network (adhoc device needs no
config), so user friendly;
The app can use the all of the features of WIFI;
Device is isolated from the internet and provides own network
The idea:
The app discovers the available WIFI-networks when no device is
configurated yet;
The device can be found via an SSID prefix, for example 'umix_' and user can select the unique correct name after the prefix, for example: 123456 (= umix_123456);
Once successfully connected, this name will be used to connect;
User can use the device via WIFI;
When exit the app or device go to sleep it reconnects to previous network;
When the app is active on wake up, it reconnects to the device it's network.
Maybe the described behaviour looks like a bluetooth connection, however, it is not because it is WIFI, better bandwidth for example and server facilities. However, the easy of use for it's user is similar to bluetooth, I want to achieve this.
Because I cannot find any info on this on the net, I ask it here. Is what I want possible anyway? Any directions, links, code examples?

Choosing WiFi network from app on Android Things device (Raspberry Pi 3)

I'm running Android Things on a Raspberry Pi 3 with a touch screen attached.
I would like to be able to access and update wifi settings in my app. I.e. be able to show a list of scanned wifi networks and let the user pick one and type in a password.
This would be useful when bringing the device to another building with a different wifi network, for example.
Is this possible? Or is the only way to change the wifi connection to do one of the actions described here: https://developer.android.com/things/hardware/raspberrypi.html#connecting_wi-fi
Thanks!
There are APIs which can be used to setup Wi-Fi networks programmatically. This means you can do all the scanning and connecting inside of your app.

How can I **disable** the Internet?

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.

Keep mobile Data always on function

If you go through HTC phones, they have an option for mobile data network setting to "Always enable mobile data". As I understand, it helps to maintain a TCP connection. I want to implement the same functionality, how to implement it ?
as I think, need to use wakelock?
WakeLocks are a Power Manager system Service feature, available to your
applications to control the power state of the host device.
You cannot change the connection (Mobile or wifi). But you can listen the connection instantly and let your application works on only mobile data.

Is it possible to force network traffic through Wifi or the TMobile network?

I'm wondering if, with the G1, it's possible to force the network traffic to pass through the Wifi or through the Cell GSM network. I need to force an application to connect through the tower network to get some login information. Is this possible? Anyone have any ideas as to how this would be possible? I'm trying to accomplish this inside an app with the Android SDK (Sorry I wasn't more clear about that originally)
It turns out to be possible using the WifiManager object to disable and then re-enable the connection. You can block it for the duration of a network call if you want to force data over the cell network. I imagine there is a similar GSM network manager out there which will do a similar task for the cell connection.
I'm assuming that you can simultaneously communicate via either channel, so at some level there aught to be separate network interfaces for each. Since android is based on linux, you could try using ifconfig or a library function to determine which interfaces are available, and which does what. If you can accomplish this, there should be a way to explicitly send/recv via the channel you want (i.e. by communicating via the ip for that interface).
Sorry I couldn't be more specific.
What you are looking for on the G1 is to set the default route. You may do so using the linux utility aptly named route, the default route is going to be to ip 0.0.0.0 and then the gateway.
Not sure if you can do this per application, but you can do it system wide!

Categories

Resources