From Clomosy Docs

Revision as of 12:49, 18 November 2024 by ClomosyManager (talk | contribs)

The TclDeviceManager component is used to interact with devices. This component allows you to control the properties and functions of devices.
Properties include:

- Vibration
- Battery level
- Access to the phonebook
Feature Use of Definition
TclDeviceManager DeviceManager1:TclDeviceManager; Variable is defined.
TclDeviceManager.Create DeviceManager1 = TclDeviceManager.Create; TclDeviceManager is created on the project.
Vibrate DeviceManager1.Vibrate(500); It is used to control the vibration feature of the device. In the example, it was vibrated for 500 milliseconds.
BatteryStatus DeviceManager1.BatteryStatus Indicates the battery level of the device.
GetAddressBookContacts DeviceManager1.GetAddressBookContacts('ConList'); Provides access to the phone book of the device. In the example 'ConList' is a procedure.
ContactsList DeviceManager1.ContactsList.Text Returns a list representing contacts in the device's address book.
CallOnAfterListProcName DeviceManager1.CallOnAfterListProcName Specifies the name of the procedure to be called after obtaining the list of phonebook contacts on the device.

Example

In the example, vibration and battery level are displayed, and names retrieved from the phonebook are listed in a Memo.

 var
   MyDevice:TclDeviceManager;
   i : Integer;
   Memo1 : TclMemo;
   MyForm : TclForm;
 void ConList;
 {
 //ShowMessage(MyDevice.ContactsList.Text); 
   try
     for (i = 0 to MyDevice.ContactsList.Count - 1)
     {
       Memo1.Lines.Add('Name: ' + Clomosy.StringListItemString(MyDevice.ContactsList,i));
       Memo1.Lines.Add('---');
     }
   finally
     MyDevice.ContactsList.Free;
   }
 }
 {
   MyForm = TclForm.Create(Self);
   
   Memo1 = MyForm.AddNewMemo(MyForm,'Memo1','');
   Memo1.Align = alClient;
   Memo1.Margins.Left= 10;
   Memo1.Margins.Right= 10; 
   Memo1.Margins.Top= 10;
   Memo1.Margins.Bottom= 10;
   Memo1.ReadOnly = True;
   Memo1.TextSettings.WordWrap = True;
   
   MyDevice=TclDeviceManager.Create;
   ShowMessage(MyDevice.BatteryStatus);
   MyDevice.Vibrate(500);
   MyDevice.GetAddressBookContacts('ConList');
   ShowMessage('List Name: '+MyDevice.CallOnAfterListProcName);
   
   MyForm.Run;
 }

See Also