![]()
Try to acquire ANDROID_ID and identifierForVendor(IDFV) using C++Builder.
ID |
Description |
ANDROID_ID |
ANDROID_ID is a character string randomly generated at the time of initialization of Android terminal. |
identifierForVendor(IDFV) |
identifierForVendor(IDFV) is an ID that can be used from iOS 6.0 as an alternative to iOS UDID. In applications with different vendors (developers), different IDs are returned.You can get the same value among multiple applications,It is not guaranteed that different values will return on different terminals. |
uGetUuid.hpp
#if defined(_PLAT_IOS)
#include <Macapi.Helpers.hpp>
#include <iOSapi.UIKit.hpp>
#elif defined(__ANDROID__)
#include <Androidapi.Helpers.hpp>
#include <Androidapi.JNI.Provider.hpp>
#else
#include <IdIPWatch.hpp>
#endif
struct TGetUUID
{
static const UnicodeString get_uuid();
};
cpp
const UnicodeString TGetUUID::get_uuid()
{
#if defined(_PLAT_IOS)
_di_UIDevice device_ = TUIDevice::Wrap(TUIDevice::OCClass->currentDevice());
return NSStrToStr(device_->identifierForVendor()->UUIDString());
#elif defined(__ANDROID__)
using namespace Androidapi::Jni::Provider;
using namespace Androidapi::Helpers;
return JStringToString(
TJSettings_Secure::JavaClass->getString(
SharedActivity()->getContentResolver(),
TJSettings_Secure::JavaClass->ANDROID_ID
));
#else
#endif
}
How to use
In the button click event, return ID to Edit1->Text.
Unit1.cpp
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Edit1->Text = TGetUUID::get_uuid();
}
//---------------------------------------------------------------------------
The code written in Delphi is the following URL.
https://community.embarcadero.com/answers/device-information