T
T
trbrmrdr2020-11-20 20:07:34
Android
trbrmrdr, 2020-11-20 20:07:34

Network access via gsm with a connected wifi point without a network on Android 10?

There is an Android and a device connected via wifi. (the device itself does not have access to enthernet)
When connected to it, Android does not have a network to access the server.
I got around the problem by connecting to the device and disconnecting. And then connected to the server.
Android 10 came out - and now you can't disconnect from the network (I turned off the wifi module).
The connection and disconnection process itself should occur automatically without the knowledge of the user!
How can you access a network without disconnecting from wifi that does not have access to ethernet?
The gsm has access to the network - I did not find anything on this topic.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
T
trbrmrdr, 2020-11-24
@trbrmrdr

There is no Internet access in the WiFi network - so on purpose.
Found a solution.
First we request access to use wifi -

val networkRequest = NetworkRequest.Builder()
                .addTransportType(NetworkCapabilities.TRANSPORT_WIFI)
                .removeCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
                .setNetworkSpecifier(
                        WifiNetworkSpecifier.Builder()
                                .setSsid(ssid)
                                .setWpa2Passphrase(pass)
                                .build()
                )
                .build()
...

After we request access to use the Internet
and use it to check access
val request = NetworkRequest.Builder()
                .addTransportType(NetworkCapabilities.TRANSPORT_CELLULAR)
                .addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
                .build()

        _cm.registerNetworkCallback(request, object : ConnectivityManager.NetworkCallback() {
            override fun onAvailable(network: Network) {
                if (server_test(network))
                    _cm.bindProcessToNetwork(network)

                LogUtils.i("onAvailable")
            }
}
...

As a result, we have Wifi - ip through broadcast
and access to the network
access to the network after is available on the entire device - earlier, on the entire Android device, the network was blocked and nothing worked.

V
Vladislav, 2020-11-22
@Risurects

Of course, you described the problem quite difficultly, for a long time I could not understand what was not working and what was needed.
Try in the "For Developers" section to find and enable the "Do not disable data transfer" setting.
(in the screenshot below)

spoiler
5fba212292815792043061.jpeg

R
rPman, 2020-11-24
@rPman

It all depends on what it means

При подключении к ней, в Android нет сети, для доступа к серверу.

Why, when wifi is physically reconnected, it is all the more incomprehensible, but the reasons definitely need to be looked for in the router.
I can assume that wifi is configured incorrectly (or on purpose) and does not give out all the necessary data such as a gateway or dns (although android can automatically take Google's 8.8.8.8, but if you have your own network and an internal dns that does not go outside, then, logically, Google does not know about it and does not work as expected)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question