yosefk

yosefk

Creating Hotspot network - it registers the I/F in NetworkInterfaces but it does not in ConnectivityManager

I’m creating Hotspot network in Android by
WifiManager.startLocalOnlyHotspot. It register the I/F in NetworkInterfaces but it does not in ConnectivityManager.
I need to bind DatagramSocket to hotspot interface by ConnectivityManager network, but associate the two.

First Post!

premsinghsodha7

premsinghsodha7

Are you running the socket on the phone hosting the hotspot, or on a client connected to it? The distinction matters here.

A NetworkInterface is an OS interface; it is not itself an android.net.Network that you can pass to Network.bindSocket(). Finding the hotspot interface in NetworkInterface.getNetworkInterfaces() therefore does not supply the missing Network object.

If this is a UDP server on the hosting phone, first test ordinary unicast traffic from a connected client. You can bind a DatagramSocket to a local address and port using InetSocketAddress; that is different from binding the socket to an Android Network. Use an address actually assigned to the hotspot interface, rather than assuming an interface name or a fixed IP. Local-address binding is not a general replacement for Android network selection, so confirm packet delivery on the affected device.

If this is the client, use the Wi-Fi Network delivered through the appropriate connectivity callback, and bind the socket before connecting it.

Could you share your Android version, which side runs this code, and whether the traffic is unicast, broadcast, or multicast? Those cases need different handling.

References: local-only hotspots, DatagramSocket address binding, Network socket binding.

Where Next?

Popular Android topics Top

Exadra37
I am in the process of research for my next technical blog about bypassing certificate pinning with Frida, thus I need to find some open ...
New
AndroidMan
I’ve tried signing up for Airnow as I used to do very well when they were Airpush, but i haven’t used them in years. I went through the s...
New
Shadow
Good afternoon. Brief story: My institution has several nfc tags in building which have to be scanned with specific app built and used in...
New
faust
Honest question, do companies still use Java for their new android apps? I thought everybody was using Kotlin these days.
New
skysnap
Helo, I’m using doubleviewpager in my project: Is there something similar that works with android x?
New
Garrett
This is a question about Android Studio. Where is the Android Studio emulator’s camera default apartment 3D model stored in Android Stud...
New
Devraj5032
I’m using TensorFlow Lite (TFLite) with React Native Expo. When I test the app using the Expo Go app, everything works fine. However, whe...
New
Alan
I need to create an android app to receive contactless payment from my clients. how can I start that? My clients will be phisicaly in the...
New
yosefk
I’m creating Hotspot network in Android by WifiManager.startLocalOnlyHotspot. It register the I/F in NetworkInterfaces but it does not i...
New
bee
Hi, I’d like a class that I can access from all activities / views, which is initialised once and not need to pass the reference. I gues...
New

Other popular topics Top

PragmaticBookshelf
Learn from the award-winning programming series that inspired the Elixir language, and go on a step-by-step journey through the most impo...
New
Exadra37
Please tell us what is your preferred monitor setup for programming(not gaming) and why you have chosen it. Does your monitor have eye p...
New
brentjanderson
Bought the Moonlander mechanical keyboard. Cherry Brown MX switches. Arms and wrists have been hurting enough that it’s time I did someth...
New
AstonJ
I’ve been hearing quite a lot of comments relating to the sound of a keyboard, with one of the most desirable of these called ‘thock’, he...
New
Exadra37
I am asking for any distro that only has the bare-bones to be able to get a shell in the server and then just install the packages as we ...
New
mafinar
This is going to be a long an frequently posted thread. While talking to a friend of mine who has taken data structure and algorithm cou...
New
PragmaticBookshelf
Author Spotlight Jamis Buck @jamis This month, we have the pleasure of spotlighting author Jamis Buck, who has written Mazes for Prog...
New
Help
I am trying to crate a game for the Nintendo switch, I wanted to use Java as I am comfortable with that programming language. Can you use...
New
AstonJ
If you want a quick and easy way to block any website on your Mac using Little Snitch simply… File > New Rule: And select Deny, O...
New
PragmaticBookshelf
Leverage Elixir and the Nx ecosystem to build intelligent applications that solve real-world problems in computer vision, natural languag...
New