All Projects → anitaa1990 → Wifi-Connect

anitaa1990 / Wifi-Connect

Licence: Apache-2.0 license
A library project to connect two devices using Wifi-Direct

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Wifi-Connect

playercast
Cast to media player and control playback remotely.
Stars: ✭ 46 (-51.06%)
Mutual labels:  receiver, sender
rsync
gokrazy rsync
Stars: ✭ 308 (+227.66%)
Mutual labels:  receiver, sender
Sharex
ShareX is a free and open source program that lets you capture or record any area of your screen and share it with a single press of a key. It also allows uploading images, text or other types of files to many supported destinations you can choose from.
Stars: ✭ 18,143 (+19201.06%)
Mutual labels:  share
chef-android-sdk
Development repository for Android SDK Chef Cookbook
Stars: ✭ 26 (-72.34%)
Mutual labels:  android-sdk
WormHole
WormHole allows to share classes between Flutter and Native Platform (android / ios)
Stars: ✭ 36 (-61.7%)
Mutual labels:  share
epsAndroidPlayer
易居PGC直播Saas平台Android播放器SDK,Android平台原生播放器,性能高,画质好,直播延迟最低可达1秒。支持HLS,RTMP等流媒体协议,支持H264,AAC音视频编码技术。可灵活设置画幅,显示方向。
Stars: ✭ 13 (-86.17%)
Mutual labels:  android-sdk
tcloud-heroku
File sharing and torrent downloading
Stars: ✭ 24 (-74.47%)
Mutual labels:  share
Sdk3rd
第三方SDK集成库,授权/分享/支付
Stars: ✭ 249 (+164.89%)
Mutual labels:  share
gqrx
Software defined radio receiver powered by GNU Radio and Qt.
Stars: ✭ 2,345 (+2394.68%)
Mutual labels:  receiver
vue-socials
💬 Social media share buttons and counts for Vue.js
Stars: ✭ 32 (-65.96%)
Mutual labels:  share
miraclecast
Connect external monitors to your system via Wifi-Display specification also known as Miracast
Stars: ✭ 17 (-81.91%)
Mutual labels:  wifi-direct
buttons
Make sharing fast and secure.
Stars: ✭ 18 (-80.85%)
Mutual labels:  share
filein-frontend
The best way to share files
Stars: ✭ 16 (-82.98%)
Mutual labels:  share
SuperGrate
💾 Get moving with Super Grate; a free & open source Windows Profile Migration & Backup Utility. Super Grate is a GUI (Graphical User Interface) that assists Microsoft's USMT (User State Migration Utility) in performing remote migrations over a network connection.
Stars: ✭ 91 (-3.19%)
Mutual labels:  share
note
笔记分享 | Note Share
Stars: ✭ 83 (-11.7%)
Mutual labels:  share
ZTVendorManager
基于友盟集成QQ,微信 ,微博 分享和登录功能,支付宝和微信支付功能。集成简单,使用方便。
Stars: ✭ 26 (-72.34%)
Mutual labels:  share
React Native Share
Social share, sending simple data to other apps.
Stars: ✭ 2,955 (+3043.62%)
Mutual labels:  share
no-clipboard-app
Share your clipboard text to your device like Oculus Go.
Stars: ✭ 12 (-87.23%)
Mutual labels:  share
direct-net-share
share internet via Wifi direct on Android
Stars: ✭ 36 (-61.7%)
Mutual labels:  wifi-direct
shared-react-components-example
An example of a mono-repository of shared React components libraries!
Stars: ✭ 85 (-9.57%)
Mutual labels:  share

152px

Wifi-Connect

Android Arsenal

A simple wrapper module to connect two devices and share data using Wifi-Direct.

This library provides an easy way to access the wifi direct api provided by Android without having to deal with all the boilerplate stuff going on inside.

Sample App

Get it on Google Play

Download the sample app on the Google Play Store and check out all the features

API

How to integrate the library in your app?

Gradle Dependecy - Java
dependencies {
    implementation 'com.wifiscanner:wifiscanner:0.1.2'
}

Maven Dependecy - Java

<dependency>
  <groupId>com.wifiscanner</groupId>
  <artifactId>wifiscanner</artifactId>
  <version>0.1.2</version>
  <type>pom</type>
</dependency>

Usage

Step 1:Define the AndroidManifest.xml class:
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

Declare the following service:

<service android:enabled="true" android:name="com.wifiscanner.server.ServerDataService" />

Note: Currently the app does not support runtime permissions.


Step 2: Define the wrapper class in the onCreate() method of the activity

WifiP2PService wifiP2PService = new WifiP2PServiceImpl.Builder()
                .setSender(this)
                .setWifiP2PConnectionCallback(this)
                .build();
        wifiP2PService.onCreate();

We need to initialize the wrapper class and declare the activity as either the Sender or the Receiver. For instance, in order to declare the activity as a Sender class, we use .setSender(this). In order to declare the activity as a Receiver class, we use .setReceiver(this)

The Receiver - will act as the server. It will fetch the list of available nearby devices and select a device to connect with. The Sender - will act as the client. Once a connection request is made from the server, the sender will accept the connection and pass data to the Receiver


Step 3: Add the following method in the onResume method of the activity

wifiP2PService.onResume();

This method will register the broadcast receiver that will listen for the changes in Wifi network.


Step 4: Add the following method in the onStop method of the activity

wifiP2PService.onStop();

This method will unregister the broadcast receiver since the activity is no longer at the top of the activity.


Step 5: Implement the WifiP2PConnectionCallback interface in your activity

public class MainActivity extends AppCompatActivity implements WifiP2PConnectionCallback {

Functions in the WifiP2PConnectionCallback interface

Function Name Usage
initiateDiscovery() This callback method is called when the scan is first initiated
onDiscoverySuccess() This callback method is called the discovery is successful
onDiscoveryFailure() This callback method is called the discovery is not successful
onPeerAvailable() This callback method is called with a list of all peer available devices
onPeerStatusChanged() This status of the peers that are discovered is changing
onPeerConnectionSuccess() called when a connection to a nearby device is successful
onPeerConnectionFailure() called when a connection to a nearby device is not successful
onPeerDisconnectionSuccess() called when a disconnection to a nearby device is successful
onPeerDisconnectionFailure() called when a disconnection to a nearby device is not successful
onDataTransferring() called when data transfer has been initiated
onDataTransferredSuccess() called when data transfer has completed & is successful
onDataTransferredFailure() called when data transfer has completed & is not successful
onDataReceiving() Called when the receiver has started to receive the data from sender
onDataReceivedSuccess(String message) Called when the receiver has received the data successfully
onDataReceivedFailure() Called when the data transferred is completed but data is not received


Methods available in the Receiver class: Method to connect to an available device: - you need to pass the device that is to be connected wifiP2PService.connectDevice(wifiP2pDevice);


Method to start data transfer - you need to pass the message that needs to be shared to the client wifiP2PService.startDataTransfer("Helllooo");


And that's it folks!

Created and maintained by:

Anitaa Murthy [email protected]

Twitter Google Plus Linkedin

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].