Display Wifi Hotspot Clients Past Times Truthful Cat /Proc/Net/Arp

Posted on

This instance display WiFi Hotspot connected clients (with IP in addition to MAC address) yesteryear Linux ascendency “cat /proc/net/arp”, using ProcessBuilder.

(You tin download runnable APK from link on bottom)

Tethering OFF, every bit WiFi client.

Tethering ON, amongst no customer connected.

Tethering ON, amongst 2 clients connected; Nexus vii in addition to Raspberry Pi + WiFi dongle.

But, later on whatsoever customer disconnected, the /proc/net/arp volition non updated immediately; I don’t know how long it volition refresh. One agency to update arp is plough OFF in addition to ON tethering again.

Tested on unrooted Xiaomi Redmi 2 running Android 4.4.4.


package com.blogspot.android_er.androidlistclient;  import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.widget.Button; import android.widget.TextView;  import java.io.IOException; import java.io.InputStream;  world class MainActivity extends AppCompatActivity {      Button btnRead;     TextView textResult;      //String[] args = {"/system/bin/cat", "/proc/net/arp"};     String[] args = {"cat", "/proc/net/arp"};      @Override     protected void onCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);         setContentView(R.layout.activity_main);         btnRead = (Button)findViewById(R.id.readclient);         textResult = (TextView)findViewById(R.id.result);          btnRead.setOnClickListener(new View.OnClickListener() {             @Override             world void onClick(View v) {                 textResult.setText(toRead());             }         });     }      somebody String toRead()     {         ProcessBuilder cmd;         String result="";          try{             cmd = novel ProcessBuilder(args);              Process procedure = cmd.start();             InputStream inwards = process.getInputStream();             byte[] re = novel byte[1024];             while(in.read(re) != -1){                 System.out.println(new String(re));                 outcome = outcome + novel String(re);             }             in.close();         } catch(IOException ex){             ex.printStackTrace();         }         provide result;     } }  


<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:tools="http://schemas.android.com/tools"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:padding="16dp"     android:orientation="vertical"     tools:context="com.blogspot.android_er.androidlistclient.MainActivity">      <TextView         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_gravity="center_horizontal"         android:autoLink="web"         android:text="https://rootandroid.org//"         android:textStyle="bold" />          <Button         android:id="@+id/readclient"         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:textAllCaps="false"         android:text="Read /proc/net/arp"/>      <TextView         android:id="@+id/result"         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:typeface="monospace"         android:textSize="12sp"/> </LinearLayout>  

You tin download runnable APK from link on bottom Display WiFi Hotspot clients yesteryear truthful cat /proc/net/arpDownload runnable APK .

This instance display arp inwards human readable format, simply non for machine. Next post “Retrieve IP in addition to MAC addresses from /proc/net/arp” larn it inwards to a greater extent than machine readable.