FMX.DeviceInfo Sample
This sample shows you how to obtain device information that includes OS version, OS name and device type.
Contents
Location
You can find the DeviceInfo sample project at:
- Start | Programs | Embarcadero RAD Studio Athens | Samples and then navigate to:
Object Pascal\Mobile Snippets\DeviceInfo
CPP\Mobile Snippets\DeviceInfo
- Subversion Repository:
- You can find Delphi and C++ code samples in GitHub Repositories. Search by name into the samples repositories according to your RAD Studio version.
Description
The DeviceInfo sample demonstrates how to obtain device information of an iOS or Android device. This sample uses the iOS or Android APIs to obtain the OS version, the OS name and the device type.
How to Use the Sample
- Navigate to one of the locations given above and open:
- Delphi: DeviceInfo.dproj.
- C++: DeviceInfo.cbproj.
- Select the target platform, iOS and Android supported.
- Press F9 or choose Run > Run.
- Click on the refresh tool button at the upper right corner to obtain the following device information:
- OS Name
- Device Type
- OS Version
Files
File in Delphi | File in C++ | Contains |
---|---|---|
DeviceInfo.dproj |
DeviceInfo.cbproj |
The project itself. |
uMain.fmx |
uMain.fmx |
The main form where the components are located. |
uMain.pas |
DeviceInfoPCH.h, TapAndHold.cpp |
Used to define and implement the sample. |
Information.txt |
Information.txt |
Further information about the sample. |
Clases
TDeviceInfoForm is the main form that represents the main window of the sample. It contains the following components:
- A TListBox object with three TListBoxItems.
- A TListBoxItem1 called lbOSName
- A TListBoxItem2 called lbDeviceType
- A TListBoxItem3 called lbOSVersion
- A TToolBar object with a TButton object called btnGetDeviceInfo and a TLabel object.
Implementation
- The sample uses TListBox to display a set of information items related with the device and the OS.
- The sample uses each TListBoxItem to display each information item.
- The sample uses a TButton component called btnGetDeviceInfo to call the OnClick event that is used to get the device information.
When you run the application, you can see at the upper right corner a button with the StyleLookup set to refreshtoolbuttonbordered. Click on it to obtain the following information of your device:
- OS Name
- Device Type
- OS Version
Uses
The sample uses Built-in Java libraries for Android
- androidapi.JNI.JavaTypes
- androidapi.Helpers
- androidapi.JNI.Os
The sample uses iOS Objective-C Frameworks
- iOSapi.UIKit
- iOSapi.Foundation
- Macapi.Helpers