How to get UDID of device selected by appium server for current execution?

As if there are multiple devices are connected to system ,appium picks-up first device in ‘adb devices’ out-put.
So how can I get device UDID of device being used for current execution?

To get the android device id, you would use this command

appium_driver.device_uuid

If you want to assign a particular android device for testing when you have multiple ones connected, use the -U parameter when starting the server.

Actually the problem is not of assignment but getting UDID after assignment by appium while execution. So how can I? Need to use same value in my code(Java)

The call I gave above was in Ruby. It’s likely a similar call is available in Java, e.g. appium_driver.deviceUuid.

Thanks,All.
Solved this issue with help of ‘getSessionDetails()’ method from appium driver.