RxWifiP2pManager


Source link: https://github.com/mrmitew/RxWifiP2pManager

RxWifiP2pManager (DEPRECATED)

A library allowing you to manage Wi-Fi peer-to-peer connectivity in a reactive way. The library itself is a RxJava wrapper for Android's WifiP2pManager, used for discovering available peers, setup connection to peers and query for the list of peers.

When a p2p connection is formed over wifi, devices continue to maintain the uplink connection over mobile or any other available network for internet connectivity. For more information, please refer to https://developer.android.com/reference/android/net/wifi/p2p/WifiP2pManager.html

Requirements

Min sdk is API level 14.

Some examples

Instantiation of RxWifiP2pManager

mRxWifiP2pManager = new RxWifiP2pManager(

 getApplicationContext(),

 (WifiP2pManager) getSystemService(Context.WIFI_P2P_SERVICE),

 new WifiP2pBroadcastObservableManagerFactory(getApplicationContext()));

Request current p2p peers

mRxWifiP2pManager.requestPeers()

  .subscribeOn(Schedulers.computation())

  .observeOn(AndroidSchedulers.mainThread())

  .subscribe(wifiP2pDevice -> Log.d("log", "Device found: " + wifiP2pDevice.deviceName));

Discover and request all nearby p2p peers

mRxWifiP2pManager.discoverAndRequestPeers()

  .timeout(5, TimeUnit.SECONDS) // Optional, but recommended

  .subscribeOn(Schedulers.computation())

  .observeOn(AndroidSchedulers.mainThread())

  .subscribe(wifiP2pDevice -> Log.d("log", "Device found: " + wifiP2pDevice.deviceName));

Discover and request a list with all current nearby p2p peers

mRxWifiP2pManager.discoverAndRequestPeersList()

  .timeout(5, TimeUnit.SECONDS) // Optional, but recommended

  .subscribeOn(Schedulers.computation())

  .observeOn(AndroidSchedulers.mainThread())

  .subscribe(wifiP2pDeviceList -> Log.d("log", Arrays.toString(wifiP2pDeviceList.getDeviceList().toArray())));

Initiation of a peer discovery

mRxWifiP2pManager.discoverPeers()

  .subscribeOn(Schedulers.computation())

  .observeOn(AndroidSchedulers.mainThread())

  .subscribe(() -> Log.d("log", "Discover completed"));

Initiation of a connection request to a peer

mRxWifiP2pManager.connect(mRxWifiP2pManager.createConfig("<mac address>", WpsInfo.PBC))

  .subscribeOn(Schedulers.computation())

  .observeOn(AndroidSchedulers.mainThread())

  .subscribe(() -> Log.d("log", "Connected"));

Requesting information about the current connection

mRxWifiP2pManager.requestConnectionInfo()

  .subscribeOn(Schedulers.computation())

  .observeOn(AndroidSchedulers.mainThread())

  .subscribe(wifiP2pInfo -> Log.d("log", wifiP2pInfo.toString()));

Remove an existing p2p group

mRxWifiP2pManager.disconnect()

  .subscribeOn(Schedulers.computation())

  .observeOn(AndroidSchedulers.mainThread())

  .subscribe(() -> Log.d("log", "Disconnected"));

To-do

Not all APIs from Android's WifiP2pManager are included into this library, so this is something to do for a future release. PRs are welcome! :)

Sample app

Demonstrates several of the RxWifiP2pManager's APIs, including:

  • discovering nearby p2p devices
  • connecting to a device
  • requesting/displaying connection information
  • disconnect from an existing p2p group

You can either build it yourself or download it from the Google Play Store: https://play.google.com/store/apps/details?id=com.stetcho.rxwifip2pmanager.app

Screenshots

Dependencies

Sample app

dependencies {

  compile fileTree(dir: 'libs', include: ['*.jar'])
  androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {

exclude group: 'com.android.support', module: 'support-annotations'
  
}
)
  compile 'com.android.support:appcompat-v7:25.0.0'
  compile 'com.android.support:design:25.0.0'
  testCompile 'junit:junit:4.12'

debugCompile 'com.squareup.leakcanary:leakcanary-android:1.4-beta2'
  releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta2'
  testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta2'

compile project(":library")

// SVG lib
  compile 'com.pixplicity.sharp:library:1.0.2@aar'

// Butterknife
  compile 'com.jakewharton:butterknife:8.1.0'
  apt 'com.jakewharton:butterknife-compiler:8.1.0'

// RxJava
  compile "io.reactivex:rxjava:1.2.1"
  compile "io.reactivex:rxandroid:1.2.1" 
}

Library

dependencies {

  compile fileTree(dir: 'libs', include: ['*.jar'])
  androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {

exclude group: 'com.android.support', module: 'support-annotations'
  
}
)
  testCompile 'junit:junit:4.12'

// RxJava
  compile "io.reactivex:rxjava:1.2.1"

// RxBroadcast
  compile 'com.cantrowitz:rxbroadcast:1.1.0' 
}

Build

$ git clone https://github.com/mrmitew/RxWifiP2pManager.git $ cd rxwifip2pmanager/ $ ./gradlew build

Communication

  • Author: Stefan Mitev
  • E-mail: mr.mitew [at] gmail . com
  • Github issues

Bugs and Feedback

For bugs, questions and discussions please use the Github issues.

Changelog

1.0.1

  • Use the newest version of LeakCanary (1.5)
  • Added a custom launcher icon

1.0.0

  • Initial version

License

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.

Resources

Simple text counter animation. You need to set from number and to number! And this library will create animation. Also you can use different modes.

CameraKit is an extraordinarily easy to use utility to work with the infamous Android Camera and Camera2 APIs.

Android library to display markdown text.

Permission Manager is easily manage Android Marshmallow and nougat runtime permissions.

This library is backwards compatible. In pre-Marshmallow devices permissions are returned as given. This is done using the Android Support library AppCompatActivity and support Fragment methods for permissions.

A simple API-like from html website (scrapper) for Android.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes