Mobile Code Snippets

From RAD Studio
Jump to: navigation, search

Go Up to iOS Mobile Application Development

Go Up to Android Mobile Application Development

Mobile Code Snippets on the Welcome Page

The Mobile Code Snippets are short, targeted code samples that help you understand how to implement basic mobile functionality using RAD Studio. You can see all the mobile code snippets listed here, and some of the snippets are featured on the Welcome Page and Getting Started Page in RAD Studio, as follows:

  • The RAD Studio Welcome Page is available in the product. It provides:
    • Links to some of the Mobile Code Snippets and provides short videos to illustrate the snippets
    • Links to start the projects associated with the Mobile Code Snippets
      • Your installed samples contain a specific directory for the snippets, typically inside C:\Users\Public\Documents\Embarcadero\Studio\23.0\Samples
  • The Getting Started page for RAD Studio is available from the Welcome Page. It provides:
    • The URL of the SourceForge code repository for some of the code snippets
    • Short videos and links to the related mobile tutorials and samples (demos).

Installed Location of the Mobile Code Snippets Projects

The Mobile Code Snippets are delivered in the following language-specific folders in your product installation:

  • C:\Users\Public\Documents\Embarcadero\Studio\23.0\Samples\Object Pascal\Mobile Snippets
  • C:\Users\Public\Documents\Embarcadero\Studio\23.0\Samples\CPP\Mobile Snippets

Each snippet folder contains the files for one or more RAD Studio projects: that is, the project files, source code, form files, and an Information.txt file (a readme file) for each snippet project (for example, the Accelerometer project).

To Quickly Navigate to the Mobile Code Snippets

  1. Select Start | Programs | Embarcadero RAD Studio Athens | Samples.
  2. Open the folder for the language you are using (that is, either Delphi or C++Builder).
  3. Open the Mobile Snippets folder:
    • C:\Users\Public\Documents\Embarcadero\Studio\23.0\Samples\Object Pascal\Mobile Snippets
    • C:\Users\Public\Documents\Embarcadero\Studio\23.0\Samples\CPP\Mobile Snippets

Downloading the Latest Source Code

You can find Delphi and C++ code samples in . Search by name into the samples repositories according to your RAD Studio version.

Mobile Code Snippets List

Code Snippet Shows You How to ...
Accelerometer Use the accelerometer sensor to obtain information about the device acceleration, angular acceleration, motion, and speed.
AccessCameraApp Use standard actions to open the Camera Application on your mobile device, take a picture and retrieve the taken image for display on your multi-device form.
AudioRecPlay Record audio (sound) using the device microphone and then play the sound back using the device speakers or headphones.
CameraComponent
Manipulate the camera on your mobile device, and select either the front-facing camera or the back-facing camera. You can also select whether to use the flash (always on, automatic, or off).
CameraRoll Use standard actions to open the Photo Library on your mobile device and retrieve an image from the library for display on your multi-device form.
CustomPicker Use the TComboBox component to pick an item from the combobox and display the item's Text on a label.
DatePicker Use the TDateEdit component to pick dates and process them to use in your FireMonkey applications.
DeviceInfo Obtain device information that includes OS version, OS name, and device type.
FireDAC_IBLite Populate a listview from an IBLite database using FireDAC and LiveBindings.
FireDACSQLite Populate a listbox from an SQLite database using FireDAC and LiveBindings.
Gyroscope Use the Gyroscope to rotate a 3D cube when the mobile device is tilted.
HorizontalScroll Use the THorzScrollBox component to scroll through two identical pictures.
IBLite Populate a list box from an InterBaseLite database using LiveBindings.
InteractiveGestures
  • ImageRotation
  • ImageZoom
  • TapAndHold
Three separate code snippets that demonstrate how to:
  • Enable rotation for an image on a mobile device.
  • Enable Zoom in/out on an image on a mobile device.
  • Enable the Long tap (Tap and hold) gesture on a mobile device.
Location Use the TLocationSensor component in order to read the GPS location of the device and display it realtime on the form. The snippet also shows you how to use Google Maps in order to accurately pinpoint the location of the device on a real map.
MessageAlerts Pop up various alert messages, both standard one-button information box style, and multiple button input box styles that allow various confirmations.
Notifications
  • SendCancelNotification
  • SetResetBadgeNumber (iOS only)
Two separate code snippets that demonstrate how to:
  • Use the Notification API to send a notification whether delayed or not, and also to cancel all sent notifications.
  • Use the Notification API to set the badge number on the application icon or to reset the badge number to 0. (iOS only)
OrientationSensor Use the TOrientationSensor component to get various compass-related information such as three-axis tilt, distance and heading, heading relative to magnetic north compensated and uncompensated, and heading relative to true north compensated and uncompensated.
PhoneDialer Use the PhoneDialer API to make a phone call and to obtain the carrier information.
PlayAudioFile Use TMediaPlayer and include an audio file for playback on your mobile device.
ShareSheet Use standard actions to open the Camera Application on your mobile device, take a picture and retrieve the taken image for display on your multi-device form. Then with another standard action, open the sharing sheet in order to share that image with other services.
TabSliding Use a TabControl with TabPosition set to Dots to enable scrolling of tab items on mobile devices. The application has two tab items, each containing a different image.
TimePicker Use the TTimeEdit component to pick dates and process them to use in your FireMonkey applications.
VideoPlayback Play an existing video clip on your iOS or Android mobile device.
WebBrowser Use a TWebBrowser component on a mobile device. The application consists of an edit box, a button, and the web browser component. Type an address in the edit box and press the "GO" button to redirect the browser to your address.

See Also