get many MAC Address - android

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);
}

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

How to query router to find Dhcp Lease Info?

I want to get list of IP and MAC addresses of all devices assigned by router, for that I want to query router to find 'Dhcp Info' using Java in Android.
different routers provide different API. You'd better send something like a ping query to all IP adresses according to address assigned to you. Like if your IP is 192.168.0.18 then ping all IPs 192.168.0.1-192.168.0.255.
I guess this app is doing the same thing. Looks like he (the developer of the app) is also parsing the webpage to get the information.
In the images on the play store of the above app you can see he is displaying the whole router webpage and parsing the same page to get the information.
Check out the screenshot#2 of the app .
#VikramGiri To get lease duration in Android, try:
WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
wifiManager.getDhcpInfo().leaseDuration;
This works if your router utilises DHCP. For utilised static IP address, the above code will always return zero instead of a number in milliseconds representing the lease duration.
The DhcpInfo class also provide other fields you might be interested in like: DNS addresses, IP addresses, gateway, netmask, etc. See here for more info.
Since you're new here, don't forget to tick answers if they are correct so others who read your post in the future will know that a given answer(s) is/are correct...

Discovering vendor-specific bluetooth devices only

Need to discover or search for Bluetooth devices of certain "vendor-specific" devices.
"vendor-specific" means all devices will have similar starting bits in their "MAC" address
For example, I want to search only for devices whose MAC address starts with 12:34:56:
It should search only for specific series of MAC addresses and list them.
Perform a full discovery, then filter using BluetoothDevice.getAddress()
// Define Vendor ID Prefix
public static final String VENDOR_ID = "12:34:56:"
// First, do a full discovery...
BluetoothAdapter.getDefaultAdapter().startDiscovery()
//...
// Then, for each device returned from discovery...
if ( device.getAddress().startsWith(VENDOR_ID) ) {
// Do Something
}
My Explanation will be based on the BluetoothChat example from the Android SDK, hopefully this is ok, otherwise I would need to write a lot more. If you haven't seen the BluetoothChat example, go take a look, it's really nice!
If you want to use a device where you don't know the complete adress, you'll have to do a complete discovery with BluetoothAdapter.startDiscovery() and search the received addresses for the ones you want to.
If you know the complete address of the device you want to connect to you can directly connect to this device with BluetoothDevice device = mBluetoothAdapter.getRemoteDevice(address)

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 the MAC address of the closest WiFi using 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.

Categories

Resources