Skip to content

Android network library for scanning connected devices and finding traceroute.

License

Notifications You must be signed in to change notification settings

tejmagar/AndroidNetworkTools

Repository files navigation

Android Network Tools

Android Network Tools by Tej Magar

Update settings.gradle(Project Settings)

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()

        maven { url 'https://jitpack.io' }
    }
}

Update build.gradle(Module: project.app)

implementation 'com.github.tejmagar:AndroidNetworkTools:1.0.2alpha'

Sample code

NetworkScanner.init(this);

NetworkScanner.scan(new OnNetworkScanListener() {
    @Override
    public void onComplete(List<Device> devices) {
        for (Device device : devices) {
            Log.d("device", device.hostname + "\n" + device.vendorName + "\n" + device.macAddress);
        }
    }

    @Override
    public void onFailed() {

    }
);

Optional

After Network scanner is initialized, you can disable MAC Address and Vendor names processing as shown below. Note: MAC Address is required to lookup vendor name.

NetworkScanner.setShowMacAddress(false);
NetworkScanner.setShowVendorInfo(false);

Traceroute

 Traceroute.init(this);
 Traceroute.start("google.com", new OnTracerouteListener() {
    @Override
    public void onRouteAdd(Route route) {
        Log.d(TAG, "traceroute: IP Address =>" + route.ipAddress + "=>"
               + "RAW: " + route.rawAddress);
    }

    @Override
    public void onComplete(List<Route> routes) {
        Log.d(TAG, "traceroute: " + "completed total: " + routes.size());
    }

    @Override
    public void onFailed() {
        Log.d(TAG, "traceroute failed");
    }
 });

Use Target SDK 29 or below for MAC Address

See: https://developer.android.com/about/versions/11/privacy/mac-address

About

Android network library for scanning connected devices and finding traceroute.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages