Reputation: 2604
I need to retrieve all available MAC addresses available in the current mobile device, and if possible the currently active network card IP address.
Upvotes: 1
Views: 3415
Reputation: 1415
Following up @wholegrain's answer and this info from the link posted by @user3631728 How can I programmatically get the MAC address of an iphone:
"In iOS 7 and later, if you ask for the MAC address of an iOS device, the system returns the value 02:00:00:00:00:00. If you need to identify the device, use the identifierForVendor property of UIDevice instead. (Apps that need an identifier for their own advertising purposes should consider using the advertisingIdentifier property of ASIdentifierManager instead.)"
if this this would be suffice, you can do something like this for IOS:
Uses
{$IFDEF IOS}
iOSApi.UIKit;
{$ENDIF}
procedure TForm1.Button2Click(Sender: TObject);
var
{$IFDEF IOS}
Device : UIDevice;
{$ENDIF}
begin
{$IFDEF IOS}
Device := TUIDevice.Wrap(TUIDevice.OCClass.currentDevice);
ShowMessage(Device.uniqueIdentifier.UTF8String);
ShowMessage(Device.identifierForVendor.UUIDString.UTF8String);
{$ENDIF}
end;
Upvotes: 3
Reputation: 144
For Android:
WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
WifiInfo wInfo = wifiManager.getConnectionInfo();
String macAddress = wInfo.getMacAddress();
Upvotes: 1