Connect to specific network SSID (hotspot) when app active - android

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?

Related

Can an app connect the mobile/smartphone to an Wifi network without going to Wifi Settings?

Does that work on Andoid and also on iOS?
To explain more, in future I would like to do that:
(1) The app would scan a QR code from a cardboard box. The QR code would contain the name of a Wifi network and such network would be really within reach of the phone (consider that).
(2) The app would connect to such Wifi network automatically, without the need to go to the 'Wifi Settings' of the phone and connect to such network manually. Consider here that the password of such Wifi network is always the same, always the same string. That is, the act of connecting the mobile to such network would be all done in app code. The need of a simple 'yes/no' confirmation for the user would be no problem.
Then, will that be possible?
Android Q can let you do that.
No sure about iOS.

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.

Free wifi only if my app is installed

I would like to simulate the scenario like it is available in some hotels. Basically, if the user connects to free wifi in a hotel he/she needs to either enter a code, or visit to predefined site to accept terms and conditions.
I would like to replicate the same on android phone, user could only connect to free wifi if my custom application is installed else not.
Is it possible?
Your only possibility if you really want to develop this as an app would be to programmatically connect to the Wifi network. This way, the user would never see the password of the hotspot (As long as the device is not rooted).
However, the user had to start the app in order to get connected to the wifi, and he could uninstall the app and still connect to the Wifi, as the system saves the wifi configuration.
If you want to go this way, you'll have to deal with the WifiManager APIs.
You might find this answer to a similar question helpful.

How to Cheat Android at checking Connectivity?

I'm doing a network App using tun as virtual network device on Android. I close other available interfaces such as eth0 (for WLAN) and rmnet0 (for 3G/GPRS) but keep my tun0 device alive and add a rule in route table
ip route add default dev tun0
so I can redirect all internet transfer into tun device (what I'm doing here is the same as OpenVPN). And then I saw the data transferring when I ping other IP. Browser and some other Apps work fine.
But some of Android Apps will check the Connectivity by ConnectivityManager before accessing netwrok. Since I close WIFI & 3G/GPRS, ConnectivityManager considers there is no connection, those Apps won't access network anymore.
So my question is:
How to CHEAT android ConnectiviyManager, make it believe that there is still an available connection (for any type)?
I don't think you can do this, and you wouldn't want to, it's a system-wide service. Imagine if your app relied on internet connectivity, but some malicious app was able to tell you there was and make your app unable to complete it's actions. It could cause a serious problem.
If your app needs to believe there is a connection in some states, I suggest you interface the connectivity / network classes, you can read the true state but then return whichever value you deem fit to your app

Restrict Android Device Wifi Connection‏

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.

Categories

Resources