0

如果手机连接到开放网络(路由器),系统会显示通知,该通知需要浏览器登录。

同样,当设备连接到 wifi(Android wifi 热点)时,是否可以显示带有自定义文本的通知,该文本打开带有意图 url 的浏览器?

笔记:

连接到 wifi 的设备没有我的应用程序。通知需要由托管 wifi 热点的 android 设备发送

4

2 回答 2

1

1) You can use BroadcastReciever "android.net.wifi.WIFI_HOTSPOT_CLIENTS_CHANGED" to detect client connection.

In your AndroidManifest:

<receiver
    android:name=".WiFiConnectionReciever"
    android:enabled="true"
    android:exported="true" >
    <intent-filter>
        <action android:name="android.net.wifi.WIFI_HOTSPOT_CLIENTS_CHANGED" />
    </intent-filter>
</receiver>

And in Activity:

IntentFilter mIntentFilter = new IntentFilter();
mIntentFilter.addAction("android.net.wifi.WIFI_HOTSPOT_CLIENTS_CHANGED");
rcv = new WiFiConnectionReciever();
registerReceiver(rcv,mIntentFilter);

2) You can also get the list of connected devices to HOTSPOT

public void getConnectedClientList() {
    int clientcount = 0;
    BufferedReader br = null;
    try {
        br = new BufferedReader(new FileReader("/proc/net/arp"));
        String line;
        while ((line = br.readLine()) != null) {
            String[] splitted = line.split(" +");
                String mac = splitted[3];
                System.out.println("Mac : Outside If "+ mac );
                if (mac.matches("..:..:..:..:..:..")) {
                    clientcount++;
                    System.out.println("Mac : "+ mac + " IP Address : "+splitted[0] );
                    System.out.println("Client_count  " + clientcount + " MAC_ADDRESS  "+ mac);
                    Toast.makeText(
                            getApplicationContext(),
                            "Client_count  " + clientcount + "   MAC_ADDRESS  "
                                    + mac, Toast.LENGTH_SHORT).show();

                }
            }

    } catch(Exception e) {
    }
}
于 2017-05-10T04:59:36.970 回答
1

现在您可以创建广泛的侦听器网络更改并调用一个意图 检查意图互联网连接

于 2017-05-10T04:42:31.983 回答