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

Exception : No resource found that matches the given name (at 'layout_behavior' with value '#string/appbar_scrolling_view_behavior')
JSON object in array retrofit
React Native assets placement
Email And UserName Is Not Shown On My Logout Activity In Facebook Sign In
Changing Polyline Google map android
android google maps marker based on string parameter
Data Collection through Accelerometer - Controlling Sampling rate
My localization using Google play Services doesn't work
How to bring Android activity to the front without bringing app to front if it is running in background?
Debugging app crashes in react native
Undo the publication of an apk on the new page
Can I turn off app update notifications in the google play and itunes app stores?
Is there a way to stop a push notification with Firebase or can I set an expire notification time?
How do I get rid of the “Cannot resolve symbol R” error? [duplicate]
Updating a ListView on MainActivity from Asynctask
How to call to a method that is in the MainActivity from another class

Categories

HOME
django
alexa-skills-kit
jmx
swt
toolbox
components
fftw
apiblueprint
solaris
package
pclxl
gradient
square
pearson-correlation
modal-dialog
project
32bit-64bit
owin
vimdiff
fhir
datastage
plink
modbus-tcp
event-sourcing
sse
swagger-2.0
articulate-storyline
gulp-watch
systemtime
roslyn
resourcebundle
flooding
exchangewebservices
iis-express
browser-sync
magento-1.8
event-flow
playstation-portable
erb
ods
railstutorial.org
health-monitoring
contract
file-sharing
strftime
openal
openrasta
clarifai
datamaps
page-replacement
aquamacs
tinkerpop
static-cast
colorbar
rsa-archer-grc
vcloud-director-rest-api
materialized-path-pattern
pytables
adafruit
spring-cloud-feign
greatest-n-per-group
beamer
i386
google-query-language
cda
turbo-prolog
yajsw
fiware-monitoring
phonertc
pax-exam
amiga
branch-and-bound
ocra
user-permissions
apache-spark-1.3
variadic-templates
boost-program-options
ssis-data-flow
punycode
buffering
extjs2
synapse
multitasking
embedded-fonts
beaker-testing
poker
epiceditor
http-status-code-410
xcode3.2
apache-whirr
oracle-enterprise-linux
saxparseexception
mysql-error-1205
dataform
linfu-dynamicproxy
netbeans6.1

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile