android


how to determine your device is connected to Wi-Fi Direct or Wi-Fi hotspot via Android programming


I want to know that my Mobile device is in Wi-Fi Direct or in hotspot connection programmatically.
Thanks please help me.
Please go through this link
Check whether android wifip2p connection was successful?
It is well explained in android developer
https://developer.android.com/guide/topics/connectivity/wifip2p.html
For wifi-direct
First add permissions in manifest
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.nsdchat"
...
<uses-permission
android:required="true"
android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission
android:required="true"
android:name="android.permission.CHANGE_WIFI_STATE"/>
<uses-permission
android:required="true"
android:name="android.permission.INTERNET"/>
Then in onCreate()
private final IntentFilter intentFilter = new IntentFilter();
...
public void onCreate(Bundle savedInstanceState) {
WifiP2pManager manager = (WifiP2pManager) getSystemService(Context.WIFI_P2P_SERVICE);
WifiP2pManager.Channel channel = manager.initialize(this, getMainLooper(), null);
intentFilter.addAction(WifiP2pManager.WIFI_P2P_CONNECTION_CHANGED_ACTION);
}
Check this link for more methods and details
For hotspot
public void getClientList() {
int macCount = 0;
BufferedReader br = null;
try {
br = new BufferedReader(new FileReader("/proc/net/arp"));
String line;
while ((line = br.readLine()) != null) {
String[] splitted = line.split(" +");
if (splitted != null ) {
// Basic sanity check
String mac = splitted[3];
System.out.println("Mac : Outside If "+ mac );
if (mac.matches("..:..:..:..:..:..")) {
macCount++;
/* ClientList.add("Client(" + macCount + ")");
IpAddr.add(splitted[0]);
HWAddr.add(splitted[3]);
Device.add(splitted[5]);*/
System.out.println("Mac : "+ mac + " IP Address : "+splitted[0] );
System.out.println("Mac_Count " + macCount + " MAC_ADDRESS "+ mac);
Toast.makeText(
getApplicationContext(),
"Mac_Count " + macCount + " MAC_ADDRESS "
+ mac, Toast.LENGTH_SHORT).show();
}
/* for (int i = 0; i < splitted.length; i++)
System.out.println("Addressssssss "+ splitted[i]);*/
}
}
} catch(Exception e) {
}
}

Related Links

trouble importing android-remote-stacktrace
ADT rev20 - apps don't install on any AVD
View will get twice at onItemClick
downloading xml from ftp in android
Notification upon ended parsing of web response
How to transfer “data” between two device (android,iphone)?
write spinner selected value to database
Using AsyncTask to download an XML file
Screen resolution / Physical size
android - showDialog(); error
linux joining multicast group setsockopt returns errno 19 device not found
Foreign keys in android 2.2 and higher
HttpURLConnection, HttpClient and HttpPost request not working with POST request in Android
Android custom row layout in ListView with flexible height
Save image to sdcard from drawble resource on Android
Is it possible to combine an Accelerometer and Digital Compass to get a fine Gyroscope?

Categories

HOME
google-app-engine
apache-jena
themes
mstest
seo
mapbox
vert.x
flume
pcl-crypto
reactive-programming
distribution
mod-security
x-cart
dynatrace
screen-readers
azure-iot-hub
mathprog
google-content-api
google-picker
production
gmm
windows-xp
blade
backpack-for-laravel
object-storage
itunes
corpus
appirater
exchangewebservices
nsurl
constexpr
autodesk-designautomation
send
left-join
autolisp
android-maps-extensions
keras-layer
modalviewcontroller
zoomify
reactivekit
timing
gdata
loading
watchface
android-ibeacon
linqpad
memory-mapping
vaadin-charts
snapchat
puredata
ovf
mongotemplate
android-testing
rxtx
filenet
rmongo
gets
flex-monkey
redistributable
parfor
pacemaker
beamer
avspeechsynthesizer
project-organization
nio2
piracy-prevention
concurrentmodification
dynamics-nav-2016
custom-errors
xvim
video-player
zen-cart
binomial-theorem
mod-proxy
cwrsync
jquery-forms-plugin
user-permissions
fits
mmwormhole
exceldatareader
browserify-shim
ssis-data-flow
deform
grails-domain-class
matrix-inverse
gae-quotas
koala
kendo-dataviz
rolify
kogrid
gpars
poker
jquery-1.9
stacky
bjyauthorize
correlated-subquery
cuda-gdb
agility.js
drawtobitmap
updatesourcetrigger
hbm2java
message-passing
openfaces
opml
request-headers
django-piston
echo3
fail-fast-fail-early

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App