Git Product home page Git Product logo

accesspoint's Introduction

accesspoint

Build Status

Manage wireless access points on Android 2.2 or later.

Note that this project is abandoned since its method doesn't work on Android 7.1 or later. Have a look at these newer alternatives that have been tested to work on Android 8.0:

Quick start

repositories {
	jcenter()
}

dependencies {
	compile 'cc.mvdan.accesspoint:library:0.2.0'
}
import cc.mvdan.accesspoint.WifiApControl;

WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
WifiApControl apControl = WifiApControl.getInstance(context);

boolean enabled = apControl.isEnabled();
int state = apControl.getState();

WifiConfiguration config = apControl.getConfiguration();
Inet4Address addr4 = apControl.getInet4Address();
Inet6Address addr6 = apControl.getInet6Address();

// These are cached and may no longer be connected, see
// WifiApControl.getReachableClients(int, ReachableClientListener)
List<WifiApControl.Client> clients = apControl.getClients()

// Wifi must be disabled to enable the access point
wifiManager.setWifiEnabled(false);
apControl.enable();

apControl.disable();
wifiManager.setWifiEnabled(true);

Remember to ask for WRITE_SETTINGS on 6.0+! The example app has a sample implementation of that. The library will not do this for you, as it involves UI interaction that should be handled and customizable by your app.

Features

  • Enabling and disabling your AP
  • Configuring your AP via WifiConfiguration
  • Getting your device's IP address in your AP network
  • Getting the list of clients connected to your AP

Permissions

You will need the following:

<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_SETTINGS"/>

How does it work?

Enabling, disabling and configuring of wireless Access Points are all unaccessible in the SDK behind hidden methods in WifiManager. Reflection is used to get access to those methods.

Getting your own IP address is done by getting the IP address that is associated with the wireless network interface.

Getting the list of clients consists of parsing /proc/net/arp and parsing each line to see what devices are neighbours in our wireless network.

An extra method is available to get the list of reachable clients, since the arp table is cached for up to a few minutes. The method asynchronously tests the reachability of each client.

License

Published under the Apache2 license.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.