locked
Discovering all devices connected to my network RRS feed

  • Question

  • User393680 posted

    Hi.. I want to create an app where I need to find devices connected to my wifi network using xamarin form

    Wednesday, August 12, 2020 7:51 AM

Answers

  • User393680 posted

    yes that worked for me sry for late reply thankyou

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Sunday, August 23, 2020 6:38 PM

All replies

  • User382871 posted

    For this feature, try use InetAddress.GetByAddress command to get the ip address of the device. ``` WifiManager wifiManager = (WifiManager)Android.App.Application.Context.GetSystemService(Context.WifiService); string wifi_Ip = IntToInetAddress(wifiManager.DhcpInfo.ServerAddress).ToString().Substring(1);

    public InetAddress getIPv4Address(int hostAddress) { byte[] addressBytes = {(byte) (0xff & hostAddress), (byte) (0xff & (hostAddress >> 8)), (byte) (0xff & (hostAddress >> 16)), (byte) (0xff & (hostAddress >> 24))};

    try
    {
        return InetAddress.GetByAddress(addressBytes);
    }
    catch (UnknownHostException ex)
    {
        throw new Java.Lang.AssertionError();
    }
    

    } ```

    Similar issue: https://forums.xamarin.com/discussion/150000/xamarin-android-get-the-ip-address-of-the-hotspot

    Wednesday, August 12, 2020 2:01 PM
  • User393680 posted

    Thanks for your reply Could you please elaborate as in where do I need to use this code and do I need install nuget package as I just have knowledge of basics

    Wednesday, August 12, 2020 2:06 PM
  • User393680 posted

    I used this and got error


    Wednesday, August 12, 2020 2:30 PM
  • User382871 posted

    For the function, you need to achieve on each platform. The function code is from native android library, try to use the code on android platform and call the method in pcl with DependencyService.

    Thursday, August 13, 2020 1:49 PM
  • User393680 posted

    thanks will try

    Friday, August 14, 2020 6:16 AM
  • User382871 posted

    Waiting for your update.

    Friday, August 14, 2020 9:37 AM
  • User393680 posted

    yes that worked for me sry for late reply thankyou

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Sunday, August 23, 2020 6:38 PM