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\18.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\18.0\Samples\Object Pascal\Mobile Snippets
  • C:\Users\Public\Documents\Embarcadero\Studio\18.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 10.1 Berlin | 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\18.0\Samples\Object Pascal\Mobile Snippets
    • C:\Users\Public\Documents\Embarcadero\Studio\18.0\Samples\CPP\Mobile Snippets

Downloading the Latest Source Code from SourceForge

Subversion context menu in Project Manager

To obtain the latest changes, you can download the code for the Mobile Code Snippets from the Subversion repository on SourceForge in several different ways. Two of the most common ways are described here.

Using the Subversion Commands in the IDE (Recommended)

In RAD Studio, right-click a Mobile Code Snippet source file in the Project Manager and choose a Subversion command from the context menu:

Commit - to commit your local changes to the project in the SourceForge repository
Commit is only available to users who have read/write permission on the SourceForge RAD Studio repository.
Update - to download the latest code changes from SourceForge to your local copy
Anyone can update their samples and mobile code snippets from SourceForge.
Browse repository - to open a browser to view and navigate the SourceForge repository
Anyone can browse the SourceForge repository.

Using the Source Forge Browser Interface

The Source Forge RAD Studio site is available here:

http://sourceforge.net/p/radstudiodemos/code/HEAD/tree/branches/RADStudio_Berlin

To download the latest source code for the Mobile Code Snippets, use either of these two procedures:

To see commit information for each file in a project, click History and then Tree.

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