简体   繁体   中英

Android: Receive packets from only one ip address

how to make my android tablet receive data packets from only one ip address through wifi and not to allow it to receive from other ip address.

here is the code

- for scan and then registering

String connectivity_context = Context.WIFI_SERVICE;
            final WifiManager wifi = (WifiManager) getSystemService(connectivity_context);  
if (wifi.isWifiEnabled()) {
                        wifi.startScan();
                    }


IntentFilter i = new IntentFilter();
i.addAction(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION);

BroadcastReceiver receiver = new BroadcastReceiver() {
    @Override
    public void onReceive(Context context, Intent i) {
        // TODO Auto-generated method stub
        ScanWiFiActivity a = ScanWiFiActivity.instance();
        WifiManager w = (WifiManager) context
                .getSystemService(Context.WIFI_SERVICE);
        List<ScanResult> l = w.getScanResults();
        a.Clear();
        for (ScanResult r : l) {
                              //do what i want with the required result
        }
    }
};
registerReceiver(receiver, i);

in the for block i will do the required things.

it has to be solved by programming

This is not possible, except by modifying the firmware.

Depending on your definition of "programming", you could probably modify iptables on a rooted device from an app running as superuser, but the crux of that (configuring iptables) is not a programming question and so is off-topic for StackOverflow.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM