get the MAC address of the closest WiFi using Android - android

Q/ Write an Android program to get the MAC address of the closest WiFi Access Point
is there any ready written program i can use ?
dose any body have information that might help me ?
thank you

See this:
http://developer.android.com/reference/android/net/wifi/WifiManager.html#getScanResults()
The BSSID is the MAC address of the AP.

Related

Getting device's Bluetooth MAC address

I need to self identify a device using its bluetooth MAC address or UUID. It seems there is no way to get a device's MAC or UUID in Xamarin, Android or iOS. Is there any way to do this? I've tried using the following statement:
macAddress = Settings.Secure.getString(mContext.getContentResolver(), "bluetooth_address");
but this is not working and reruns null, I checked the code behind Secure and there is actually no bluetooth_address. I used the same code and I easily got back bluetooth_on which is in Secure code so I'm sure the code is working but there is not any bluetooth_address.
Any idea how I can do this? If I can't get this my entire design has to change.
Best

in Wifi Direct the group owner address always be 192.168.49.1 or it changes?

in Wifi Direct the group owner address always be 192.168.49.1 or it changes?
I'm new to android. please help me.
Thanks in advance.
cheers.....
Though I strongly believe that there should be no implementation where you need to directly rely on the IP Address of the GroupOwner, according to Android Source Code(Search for SERVER_ADDRESS in the file) the IP Address of the GroupOwner is 192.168.49.1 and is final and static.
Word of Caution: This might get changed anytime in the future, and hence, you must never rely on the value itself. You should always use isGroupOwner to find out whether a device is GroupOwner or not.
This seems to be IP address 192.168.49.1.Due to DHCP it will change-unless you have a static IP.

Unknown string in Terminal

What does this mean, "android_358920041107720" and how do I get rid of this string when starting my Terminal?
I believe it came from me downloading PhoneGap/Cordova, but not entirely sure.
Any help or explanation of what I'm looking at would be greatly helpful!
Thanks.
Link to the image: http://cl.ly/image/321r1O003n13
That is an android host name identifier when requesting DHCP lease on the IP address... see this for example, that occurs on my network.
dhcpd: DHCPACK on 192.168.x.x to xx:xx:xx:xx:xx:xx
(android-acc87f3d476374c1) via eth0
It could also be used to signify the Android's host name from within the adb shell, depending on the flavour of the ROM and version used.

Get MAC Address of android device without Wifi

How do I get the MAC-Address of the network interface of an android device which doesn't have a Wifi-Interface (e.g. the android emulator)? WifiInfo obtained via the WifiManager returns null.
EDIT
To be more clear: I have to communicate with an existing network protocol (not designed by me) on the local network where I have to send the mac address of the communicating interface within the payload during a registration phase.
I'm going to take a leap and assume that you want this MAC address in order to establish a unique identifier for the device. Mac Addresses are not the way to do this.
There's an Android Developer Blog post titled "Identifying App Installations" which covers the topic of generating unique ID's fairly well, including the popular methods, and the pros/cons. It's definitely worth a read. Quite relevant to this post is the following quote:
It may be possible to retrieve a Mac address from a device’s WiFi or Bluetooth hardware. We do not recommend using this as a unique identifier. To start with, not all devices have WiFi. Also, if the WiFi is not turned on, the hardware may not report the Mac address.
The options available to you instead include TelephonyManager.getDeviceId(), android.os.Build.SERIAL, and Settings.Secure.ANDROID_ID, all of which are covered in more detail in the linked post.
Read /sys/class/net/[something]/address as a text file
But it's unlikely to be useful in the way you think.
See this post where I have submitted Utils.java example to provide pure-java implementations.
Utils.getMACAddress("wlan0");
Utils.getMACAddress("eth0");
Utils.getIPAddress(true); // IPv4
Utils.getIPAddress(false); // IPv6
What is the network interface you want the MAC address of? If there's no wifi, you certainly can't get the wifi device's MAC address. It represents the physical hardware and if that's not present, it simply doesn't exist.
To get wifi MAC of android device using adb:
adb shell getprop ril.wifi_macaddr
Use the following code in Java to get it programmatically:
Process p = Runtime.getRuntime.exec("adb", "shell", "getprop", "ril.wifi_macaddr")
BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream());
String macAddress = br.readLine();

get many MAC Address

I need to many MAC address for one Device in Android.
is it possible to get many MAC Address from one device.?
plz help me.
Chick here for documentation mac address of WiFi controller.
Click here for documentation to find mac address of bluetooth adapter.
Edit1:
If you need hardware addresses of all the Wifi access points available to you.
You have scan for the networks (See here for API)
Iterate over results to get mac address of each. (See here for API)
code will look like
List<ScanResult> scanResults= wfManager.getScanResults();
for (ScanResult scanR: scanResults){
System.out.println(scanR.BSSID);
}

Categories

Resources