How to access DeviceId (IMEI) from Android using C++ Builder XE7/FMX?

1.3k views Asked by At

The following video tutorial was a good starting point (using Vibrator as an example rather than DeviceId), but there were a few more details needing attention to transpose to C++.

I'm just getting started with Stack Exchange. Hopefully this question and answer is useful to others; the following code does work as expected.

#include <Androidapi.Helpers.hpp>
#include <Androidapi.JNI.Telephony.hpp>

// Get Device ID (IMEI) from device:
_di_JObject TelephonyServiceObj = SharedActivityContext()->getSystemService(TJContext::JavaClass->TELEPHONY_SERVICE);
_di_JTelephonyManager TelephonyManager = TJTelephonyManager::Wrap(((_di_ILocalObject)TelephonyServiceObj)->GetObjectID());
UnicodeString DeviceId = JStringToString(TelephonyManager->getDeviceId());
0

There are 0 answers