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

Search for Keyword in ListView with Custom Adapter
Does Google Tag Manager updates container in between the session
Characteristics of an audio file which has been created by cordova-media-plugin
Should I remove after using “addListenerForSingleValueEvent”
App crashes repeatedly due to empty EditText
Get a style's windowBackground attribute
Change package property in AndroidManifest depending on the applicationId in build time
GSONRequest sends empty JSON?
how to negative bigdecimal's value in android
Chrome api for Android
ViewPager Slow To Load Last Tab
Testing behavior of activity when destroying
Android laggy resize animation
How to add MultiMaps gradle to android
send Firebase CrashReporting on my email
Retrofit 2 append #Body request

Categories

HOME
microsoftgraph
android-studio-2.2
formal-languages
jax-rs
angular2-material
yahoo-finance
serialization
composite-primary-key
socket.io
sublimetext
ms-access-2016
seo
database-normalization
rom
telegram-bot
square
performancepoint
augeas
fhir
keytool
event-sourcing
firefox-addon
template-engine
swagger-2.0
windows-xp
cgbitmapcontext
pimcore
tosca
monit
jquery-callback
roundup
xunit
strongname
syntax-highlighting
fractions
iis-express
zend-debugger
git-squash
github3.py
modalviewcontroller
searchkit
ideascript
flatmap
skylink
outputcache
http-request
android-checkbox
importerror
berkeley-db-je
show-hide
snapchat
jide
configurationmanager
insight
azure-cli
modelsim
git-flow
mouseleave
flac
offline.js
baidu
polyline
change-tracking
flex-monkey
winusb
myspace
adafruit
windows-azure-queues
jboss-tools
i386
dup
eigenvector
refinerycms
hadoop-partitioning
piracy-prevention
terracotta
fiware-monitoring
fuelcms
amiga
branch-and-bound
dnssec
telepat
snackbar
kubuntu
actionfilterattribute
human-computer-interface
alternate
gnumeric
mbunit
script#
asdf
font-awesome-4.0.0
twisted.web
bjyauthorize
dopostback
frameworkelementfactory
mapping-by-code
apache-commons-dbutils
jquery-tools
django-paypal
load-time
resharper-6.0
hbm2java
message-passing
data-mapping
lobo-cobra
dsoframer
commercial-application

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App