# How do you pull a device's radio interface name directly?



## SkullOne (Jul 9, 2011)

I have no clue how to get this done.

What I want to do is pull the name of the WiFi interface and the Data interface. For example Galaxy Nexus is rmnet1 for Data and wlan0 for WiFi. I then need each to be it's own string for use elsewhere in an app. I also need to be able to pull WiFi even if WiFi is currently disabled.

I've found ways to pull all interfaces but it doesn't distinguish the difference between WiFi and Data. I could poll the WiFi connection by IP and strip out that one from the interface list but if WiFi is disabled or not connected I believe that won't work. That also leaves me with a bunch of extraneous information for the Data interface since there would be an rmnet1, rmnet2, rmnet3, rmnet4 etc etc listed when only rmnet1 is what I need.

Has anybody tried this? Is it even possible?

Thanks!

-S1


----------



## JBirdVegas (Jun 11, 2011)

you can parse the wifi interface from the build.prop

```
wifi.interface=wlan0
```
and then check the stdout from

```
cat /proc/net/dev
```
Or see here: http://stackoverflow.com/questions/7010903/network-interface-names-for-android-devices


----------



## SkullOne (Jul 9, 2011)

JBirdVegas said:


> you can parse the wifi interface from the build.prop
> 
> ```
> wifi.interface=wlan0
> ...


Thanks for the info.

If the Wifi interface is always in the build.prop that solves that issue. However, the cat command gives back more than the data interface name needed. i could parse out the WiFi interface but that still leaves plenty of extraneous data I don't need or want to use. I don't want to have the app constantly running with a broadcast to detect a change in the interface either.

I need to set parameters on both radio interfaces regardless of which one is currently being used.


----------



## JBirdVegas (Jun 11, 2011)

Setup a broadcast receiver for http://developer.android.com/reference/android/net/ConnectivityManager.html#CONNECTIVITY_ACTION ?


----------

