All Projects → pwittchen → Reactivewifi

pwittchen / Reactivewifi

Licence: apache-2.0
Android library listening available WiFi Access Points and related information with RxJava Observables

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Reactivewifi

Reactivenetwork
Android library listening network connection state and Internet connectivity with RxJava Observables
Stars: ✭ 2,484 (+1235.48%)
Mutual labels:  rxjava, rxjava2, rxandroid, rxandroid2, wifi
Swipe
👉 detects swipe events on Android
Stars: ✭ 324 (+74.19%)
Mutual labels:  rxjava, rxjava2, rxandroid, rxandroid2
Rxbus
🚌 The RxBus as steady as an old dog.
Stars: ✭ 334 (+79.57%)
Mutual labels:  rxjava, rxjava2, rxandroid, rxandroid2
ReactiveBus
🚍 Reactive Event Bus for JVM (1.7+) and Android apps built with RxJava 2
Stars: ✭ 17 (-90.86%)
Mutual labels:  rxjava, rxandroid, rxjava2, rxandroid2
Reactivebeacons
Android library scanning BLE beacons nearby with RxJava
Stars: ✭ 171 (-8.06%)
Mutual labels:  rxjava, rxjava2, rxandroid, rxandroid2
Rxbiometric
☝️ RxJava and RxKotlin bindings for Biometric Prompt (Fingerprint Scanner) on Android
Stars: ✭ 295 (+58.6%)
Mutual labels:  rxjava, rxjava2, rxandroid, rxandroid2
Prefser
Wrapper for Android SharedPreferences with object serialization and RxJava Observables
Stars: ✭ 228 (+22.58%)
Mutual labels:  rxjava, rxjava2, rxandroid, rxandroid2
Rxjavapriorityscheduler
RxPS - RxJavaPriorityScheduler - A RxJava Priority Scheduler library for Android and Java applications
Stars: ✭ 138 (-25.81%)
Mutual labels:  rxjava, rxjava2, rxandroid, rxandroid2
Android Clean Architecture Boilerplate
Apply clean architecture on Android
Stars: ✭ 141 (-24.19%)
Mutual labels:  rxjava, rxjava2, rxandroid
Freezer
A simple & fluent Android ORM, how can it be easier ? RxJava2 compatible
Stars: ✭ 326 (+75.27%)
Mutual labels:  rxjava, rxjava2, rxandroid
Dagger2
Kotlin Dagger2 example project
Stars: ✭ 145 (-22.04%)
Mutual labels:  rxjava, rxjava2, rxandroid2
Rxbluetooth
Android reactive bluetooth
Stars: ✭ 405 (+117.74%)
Mutual labels:  rxjava, rxjava2, rxandroid
Mvvm Architecture Android Beginners
This repository contains a sample app that implements MVVM architecture using Kotlin, ViewModel, LiveData, and etc.
Stars: ✭ 176 (-5.38%)
Mutual labels:  rxjava, rxjava2, rxandroid
Androidbasemvp
🚀一个快速搭建MVP+RxJava2+Retrofit 基础框架,主要是封装有Http网络请求、日志、缓存、加载等待、toast、页面状态布局管理、权限、RxBus、Glide图片加载等组件,方便快速开发新项目、减少开发成本。
Stars: ✭ 184 (-1.08%)
Mutual labels:  rxjava, rxjava2, rxandroid
Reactivesensors
Android library monitoring device hardware sensors with RxJava
Stars: ✭ 161 (-13.44%)
Mutual labels:  rxjava, rxjava2, rxandroid
rxandroid2-retrofit2
Small tutorial to get started with RxAndroid 2 and Retrofit 2
Stars: ✭ 55 (-70.43%)
Mutual labels:  rxandroid, rxjava2, rxandroid2
Rxjava2 Operators Magician
你用不惯 RxJava,只因缺了这把钥匙 🔑 You are not used to RxJava, just because of the lack of this key.
Stars: ✭ 868 (+366.67%)
Mutual labels:  rxjava, rxjava2, rxandroid
Rxbus
Event Bus By RxJava.
Stars: ✭ 2,126 (+1043.01%)
Mutual labels:  rxjava, rxjava2, rxandroid
iMoney
iMoney 金融项目
Stars: ✭ 55 (-70.43%)
Mutual labels:  rxjava, rxjava2, rxandroid2
Rxjava2 Android Samples
RxJava 2 Android Examples - Migration From RxJava 1 to RxJava 2 - How to use RxJava 2 in Android
Stars: ✭ 4,950 (+2561.29%)
Mutual labels:  rxjava, rxjava2, rxandroid

ReactiveWiFi Android Arsenal

Android library listening available WiFi Access Points and related information with RxJava Observables.

Current Branch Branch Artifact Id Build Status Maven Central
RxJava1.x reactivewifi Build Status for RxJava1.x Maven Central
☑️ RxJava2.x reactivewifi-rx2 Build Status for RxJava2.x Maven Central

This library is one of the successors of the NetworkEvents library. Its functionality was extracted from ReactiveNetwork project to make it more specialized and reduce number of required permissions required to perform specific task.

If you are searching library for observing network or Internet connectivity check ReactiveNetwork project.

JavaDoc is available at: http://pwittchen.github.io/ReactiveWiFi/RxJava2.x

Contents

Usage

Library has the following RxJava Observables available in the public API:

Observable<List<ScanResult>> observeWifiAccessPoints(final Context context)
Observable<Integer> observeWifiSignalLevel(final Context context, final int numLevels)
Observable<WifiSignalLevel> observeWifiSignalLevel(final Context context)
Observable<SupplicantState> observeSupplicantState(final Context context)
Observable<WifiInfo> observeWifiAccessPointChanges(final Context context)
Observable<WifiState> observeWifiStateChange(final Context context)

Please note: Due to memory leak in WifiManager reported in issue 43945 in Android issue tracker it's recommended to use Application Context instead of Activity Context.

Observing WiFi Access Points

Please note: If you want to observe WiFi access points on Android M (6.0) or higher, you need to request runtime permission for ACCESS_COARSE_LOCATION or ACCESS_FINE_LOCATION. After that, location services have to be enabled. See sample app in app directory to check how it's done. User needs to enable Location manually. You can suggest him or her to do it via AccessRequester class from this library as follows:

if (!AccessRequester.isLocationEnabled(this)) {
  AccessRequester.requestLocationAccess(this);
} else {
  // observe WiFi Access Points
}

If you need more customization (e.g. custom title and message of the dialog window or custom listener), check public API of the AccessRequester class.

We can observe WiFi Access Points with observeWifiAccessPoints(context) method. Subscriber will be called everytime, when strength of the WiFi Access Points signal changes (it usually happens when user is moving around with a mobile device). We can do it in the following way:

ReactiveWifi.observeWifiAccessPoints(context)
    .subscribeOn(Schedulers.io())
    ... // anything else what you can do with RxJava
    .observeOn(AndroidSchedulers.mainThread())
    .subscribe(scanResults -> {
      // do something with ScanResults
    });

Hint: If you want to operate on a single ScanResult instead of List<ScanResult> in a subscribe(...) method, consider using flatMap(...) and Observable.from(...) operators from RxJava for transforming the stream.

Observing WiFi signal level

We can observe WiFi signal level with observeWifiSignalLevel(context, numLevels) method. Subscriber will be called everytime, when signal level of the connected WiFi changes (it usually happens when user is moving around with a mobile device). We can do it in the following way:

ReactiveWifi.observeWifiSignalLevel(context, numLevels)
    .subscribeOn(Schedulers.io())
    ... // anything else what you can do with RxJava
    .observeOn(AndroidSchedulers.mainThread())
    .subscribe(level -> {
      // do something with level
    });

We can also observe WiFi signal level with observeWifiSignalLevel(final Context context) method, which has predefined num levels value, which is equal to 4 and returns Observable<WifiSignalLevel>. WifiSignalLevel is an enum, which contains information about current signal level. We can do it as follows:

ReactiveWifi.observeWifiSignalLevel(context)
    .subscribeOn(Schedulers.io())
    ... // anything else what you can do with RxJava
    .observeOn(AndroidSchedulers.mainThread())
    .subscribe(level -> {
      // do something with level
    });

WifiSignalLevel has the following values:

public enum WifiSignalLevel {
  NO_SIGNAL(0, "no signal"),
  POOR(1, "poor"),
  FAIR(2, "fair"),
  GOOD(3, "good"),
  EXCELLENT(4, "excellent");
  ...
}

Observing WiFi information changes

We can observe WiFi network information changes with observeWifiAccessPointChanges(context) method. Subscriber will be called every time the WiFi network the device is connected to has changed. We can do it in the following way:

ReactiveWifi.observeWifiAccessPointChanges(context)
    .subscribeOn(Schedulers.io())
    ... // anything else what you can do with RxJava
    .observeOn(AndroidSchedulers.mainThread())
    .subscribe(wifiInfo -> {
      // do something with wifiInfo
    });;

Observing WPA Supplicant state changes

We can observe changes in the WPA Supplicant state with observeSupplicantState(context) method. Subscriber will be called every time the WPA Supplicant will change its state, getting information at a lower level than usually available. We can do it in the following way:

ReactiveWifi.observeSupplicantState(context)
    .subscribeOn(Schedulers.io())
    ... // anything else what you can do with RxJava
    .observeOn(AndroidSchedulers.mainThread())
    .subscribe(state -> {
      // do something with state
    });

Observing WiFi state changes

We can observe wifi state change with observeWifiStateChange(context) method. Subscriber will be called every time whenever the wifi state change such like enabling,disabling,enabled and disabled. We can do it in the following way:

ReactiveWifi.observeWifiStateChange(context)
    .subscribeOn(Schedulers.io())
    ... // anything else what you can do with RxJava
    .observeOn(AndroidSchedulers.mainThread())
    .subscribe(state -> {
      // do something with level
    });

Examples

Exemplary application is located in app directory of this repository.

If you want to use this library with Kotlin, check app-kotlin directory.

Download

<dependency>
    <groupId>com.github.pwittchen</groupId>
    <artifactId>reactivewifi-rx2</artifactId>
    <version>0.3.0</version>
</dependency>

or through Gradle:

dependencies {
  implementation 'com.github.pwittchen:reactivewifi-rx2:0.3.0'
}

Code style

Code style used in the project is called SquareAndroid from Java Code Styles repository by Square available at: https://github.com/square/java-code-styles.

Static code analysis

Static code analysis runs Checkstyle, FindBugs, PMD and Lint. It can be executed with command:

./gradlew check

Reports from analysis are generated in library/build/reports/ directory.

License

Copyright 2016 Piotr Wittchen

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].