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

WebVtt subtitles not displaying( not working)
Gallery Not Showing Content
Your APK's version code needs to be higher than xxx phonegap
Everyplay not working in android vesion 5.1
GoogleApi Real Time Multiplayer pushing updates
How to pass value from onItemSelected to another spinner
OnItemClickListener for horizontal gridview
Saving canvas draw in bitmap showing white screen
How to cut off an unused space in a custom view?
How to create alerts using alarm manager and background service call and a web service call inside background service?
ActionBar menu with text ,icon,text
Firebase endAt() not working with date string?
Different splash screen on screen orientation
Visual Studio 2015. AXML. Doesn't work intellisence inside view with warning
Generate content to display on an ePaper display from Android App
Fingerprint detection stop work after the app goes to pause

Categories

HOME
algorithm
assembly
adal
linkedin
apache-jena
jax-rs
angular2-material
static
components
can
seo
edge
dojo
3d-reconstruction
azure-container-service
jtextpane
fosrestbundle
google-schemas
google-chrome-app
ibeacon-android
emoji
nancy
cumulocity
gruntfile
null-pointer
forgot-password
google-data-studio
gmm
charles
solrcloud
asp.net-core-webapi
database-connection
user-experience
ember-cli
direct3d11
strongname
google-api-client
interbase
spotipy
gp
vex
complex-numbers
database-comparison
joomla2.5
getlasterror
apollostack
android-checkbox
file-sharing
fwrite
term
vugen
payara-micro
oracleclient
sundials
dt
check-mk
css-transforms
mathcad
javafx-css
smartfoxserver
actor-platform
winusb
nupic
directdraw
vhosts
opl
avisynth
morton-number
sapscript
evolus-pencil
zscript
sql-server-data-tools
canvg
snackbar
rrule
phpldapadmin
theos
ssis-data-flow
punycode
universal-image-loader
mdichild
ss7
spring-remoting
windows-embedded-standard
visual-studio-express
redis-py
appjs
mapping-by-code
convention
tmx
cdonts
uideviceorientation
cruisecontrol.rb
tabpanel
burndowncharts
build-environment
feasibility
fail-fast-fail-early
application-planning
sqlobject
technical-debt
blind
image-capture

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