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

remove table rows except the first one
how to kill Activity permanetly After button click Using Shared prefrance
Android google cloud messaging
Android Application Design to support multiple sizes
How to show textview on Alert dialogue
android:Customize camera for QR code scanning using ZXING
Qt how connect to an existing SQLlite file in android OS?
Page curl with fragments or activities
how to get TIME for last access of an URL?
Android SQLITE database curruption [duplicate]
Camera app development and error when you tilt device
Phone call function intent not working in android
Using sparceboolean array to retain checkbox state in android for a horizontal listview
android zxing within a frame
Opening LibGDX project in Eclipse (ADT Bundle)
How can getArguments() be called in onCreate() of a Fragment..?

Categories

HOME
batch-file
windows
delphi-7
c99
github-for-windows
google-spreadsheet
flex
apiblueprint
package
graphics
devise
spring-data-redis
database-normalization
entity-framework-core
scripting
alsa
cq5
tvos
android-json
data-visualization
frontend
boto3
mel
github-enterprise
java.util.logging
mxgraph
tput
automatic-ref-counting
nancy
radgridview
code-generation
bitnami
package.json
chargify
asp.net-mvc-viewmodel
production
apache2.4
libigl
ios10.2
pimcore
tosca
flask-sqlalchemy
strongname
appirater
linked-data
sqsh
postback
paragraph
database-comparison
cart
hibernate-search
sql-delete
hivemq
sql-server-ce
tex
typesafe-config
wmp
apache-directory
facebook-social-plugins
libgphoto2
automapper-5
datamaps
google-cse
branch-prediction
cudd
builtins
microstation
preprocessor
model-associations
installshield-2010
nservicebus5
data-protection
boost-serialization
uiactionsheet
halcon
grass
invoke-sqlcmd
realsense
blitline
oracle-spatial
zen-cart
canalyzer
mod-proxy
graphics2d
node-serialport
fits
adehabitathr
beatsmusic
gii
create.js
ecslidingviewcontroller
windows-embedded-standard
rolify
neos-server
gpars
diem
joomla3.1
extreme-programming
monotouch.dialog
cross-database
stress
google-maps-mobile
expression-blend-4
update-statement
mbeans
appledoc
uideviceorientation
cruisecontrol.rb
vs-android
office-2007
jqueryform
lxr
windows-identity

Resources

Encrypt Message