Android Question MlLwifi get IP addresses

drgottjr

Well-Known Member
Licensed User
Longtime User
that library scans for access points, not nodes on your network. i think you will find those happy days of spying on who is on your network are over if you are using a recent os. "security" concerns...

see my edit below. i dug up an old routine.
 
Last edited:
Upvote 0

drgottjr

Well-Known Member
Licensed User
Longtime User
i tried a few things that used to work scanning a network. they no longer work, and sites like s.o. indicate they don't work on newer devices. if you have an old device, you can find some methods here; you just have to search (or perhaps some kind soul is familiar with one). the wifi libraries available are designed to find access points.

see edit below. at least one of the old routines still works. i forgot a permission.
 
Last edited:
Upvote 0

Tomek92

Member
Licensed User
I a lot was looking for and I finded some methods, even tried adding java function to b4a but nothing work at mine. I thinked library MLwifi will have this option that's why I asked. I wanted to do better visualization in my application but it's not necessary for it to work.
 
Upvote 0

drgottjr

Well-Known Member
Licensed User
Longtime User
i forgot a permission. one of the old routines i've used does work:

B4X:
Sub Globals
    'These global variables will be redeclared each time the Activity Is created.
    Dim ph As Phone
    Dim stdout, stderr As StringBuilder
End Sub

Sub Activity_Create(FirstTime As Boolean)
    stdout.Initialize
    stderr.Initialize
   
    ph.Shell("cat", Array As String("/proc/net/arp"), stdout, stderr)
    Msgbox(stdout.ToString & CRLF & stderr.ToString, "Arp says:")

End Sub

add the Phone library and add these permissions to the manifest:
AddPermission(android.permission.ACCESS_NETWORK_STATE)
AddPermission(android.permission.INTERNET)
AddPermission(android.permission.ACCESS_WIFI_STATE)

i ran it with sdk30
 

Attachments

  • ip.png
    ip.png
    77.7 KB · Views: 53
Upvote 0

Tomek92

Member
Licensed User
I tested your example and got a result like the picture below. Permission denied.
I tested on xiaomi redmi note 8t with android 10.
 

Attachments

  • Screenshot_2022-01-06-05-59-16-961_b4a.example2.jpg
    Screenshot_2022-01-06-05-59-16-961_b4a.example2.jpg
    96.5 KB · Views: 36
Upvote 0

drgottjr

Well-Known Member
Licensed User
Longtime User
i'm running sdk30 on android11 (pixel3a). i don't post code unless i've run it. i got that error until i added a permission i had forgotten. did you add the 3 permissions in my post? xiaomi is not google, so even though both run a version of android, they are not the same.
if you did add the permissions and it still fails, then you could try:
1) delete the app from the device
2) rebuild the example using, eg, android26 (.jar and sdk) and try it that way. even better if you have an older device. if xiaomi has closed the door on network scanning, you would need to find out when (which sdk and os). if this is something you must have, then you have to back yourself into it. at some point it was probably legal. find that point and tell your device that's the point it's at. no guarantees.
 
Upvote 0

Tomek92

Member
Licensed User
i don't post code unless i've run it
I understand and thank you for that.

I added three permissions from your post. Unless I added them wrong?
Manifest Editor:
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: https://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="30"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
CreateResourceFromFile(Macro, Themes.LightTheme)
'End of default text.
AddPermission(android.permission.ACCESS_NETWORK_STATE)
AddPermission(android.permission.INTERNET)
AddPermission(android.permission.ACCESS_WIFI_STATE)

2) rebuild the example using, eg, android26 (.jar and sdk) and try it that way.
You mean I would download the older version of Android SDK + Required Resources with the android-26 folder? And set the path in B4A to "android.jar" (C:\Android\platforms\android-26\android.jar) ?
I currently have C:\Android\platforms\android-30\android.jar
 
Upvote 0

drgottjr

Well-Known Member
Licensed User
Longtime User
unless you deleted them, the older platforms are still there. i have 28, 29 and 30. and i probably still have even older filed away. look, i don't want to mess with your system, but if having what it is that you want is important enough to you, you explore all avenues. but you'll have to do your own bookkeeping as regards the tools you use to build projects. if you're not comfortable switching sdk's, don't do it. or at least don't do it on your production maching.

arp works on my device. maybe you should try searching again, but without "milwifi". that's what got my attention in the first place because it was the wrong tool. also, at one point in time (and in a faraway galaxy), arp was what was used to identify nodes on a network. android is based on a system that supports arp. google and xiaomi are under no obligation to permit its use. xiaomi may have its own ideas about what it allows.

i just goggled around a little searching for xiaomi and /proc/net/arp. somebody posted code similar to what i posted for you. he said
Tested on unrooted Xiaomi Redmi 2 running Android 4.4.4.
so, at one point, arp worked on xiaomi devices.

note: apparently the term ARP (not arp) has a completely different meaning. ironically, ARP is the opposite of arp. if arp tells you who is on your network, ARP is software added to android to prevent you from scanning your network!!* so, if you decide to google arp and xiaomi, you will get 34,068,252 hits in 0.0002 seconds concerning ARP, not arp... if you want to know about arp (the network utility), you need to say "/proc/net/arp".

(*not quite accurate; it prevents you from loading "old" software onto your newer device, thus bypassing a loophole that would allow you to run /net/proc/arp)
 
Last edited:
Upvote 0

Tomek92

Member
Licensed User
However, I will stay with this version of the sdk and will not go back to older versions because this feature is not that important. But it's a shame it doesn't work.

Thanks to you I know that I was looking for wrong. Now I will have a different approach.

Thank you for your time and a solid dose of knowledge because you explained a lot to me.
 
Last edited:
Upvote 0
Top