Sign in Join
Wiki copytemporary

LazDeviceAPIs: what changed

Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
11LazDeviceAPIs is a LCL unit which offers an interface to various hardware devices, such as the accelerometer, GPS positioning, SMS sending, etc. It is mostly designed for smartphone/mobile platforms, but it might eventually be ported to desktops too.
22
33## Introduction
44
55LazDeviceAPIs was modeled to be similar to other APIs for hardware devices from the LCL. Historically we had two hardware global objects: Mouse and Screen, respectively for the pointing device (Mouse is also utilized for touch messages) and Screen for the display. In LazDeviceAPIs there are global objects: Accelerometer, PositionInfo, Messaging, etc.
66
77## Accelerometer
88
99The Accelerometer is very easy to use. Just call Accelerometer.StartReadingAccelerometerData to start listening to the accelerometer sensor and call Accelerometer.StopReadingAccelerometerData to stop listening to it:
1010
1111``` pascal
1212uses lazdeviceapis;
1313
1414procedure TForm2.btnStartAccelClick(Sender: TObject);
1515begin
1616 Accelerometer.OnSensorChanged := @HandleAccelerometerChanged;
1717 Accelerometer.StartReadingAccelerometerData();
1818end;
1919
2020procedure TForm2.btnStopAccelClick(Sender: TObject);
2121begin
2222 Accelerometer.StopReadingAccelerometerData();
2323end;
2424
2525procedure TForm2.HandleAccelerometerChanged(Sender: TObject);
2626begin
2727 labelSensorData.Caption := Format('X=%f Y=%f Z=%f', [Accelerometer.xaxis,
2828 Accelerometer.yaxis, Accelerometer.zaxis]);
2929 DebugLn(labelSensorData.Caption);
3030end;
3131```
3232
3333### Android Permissions
3434
3535This object requires no special permissions under Android.
3636
3737## PositionInfo
3838
3939### Android Permissions
4040
4141Using the PositionInfo global object in Android requires adding the following permissions to the AndroidManifest.xml file of the application, as can be seen below.
4242
43-`<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />`\
44-`<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />`
43+``` pascal
44+<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
45+<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
46+```
4547
4648## Messaging
4749
4850### Android Permissions
4951
5052Using the Messaging global object in Android requires adding the following permissions to the AndroidManifest.xml file of the application, as can be seen below.
5153
52-`<uses-permission android:name="android.permission.SEND_SMS" />`
54+``` pascal
55+<uses-permission android:name="android.permission.SEND_SMS" />
56+```
5357
5458## Possible Windows implementation
5559
5660Windows 7 and up has a sensors API that gives access to sensor info (e.g. GPS); see [[http://msdn.microsoft.com/en-us/library/windows/desktop/dd318936(v=vs.85).aspx|http://msdn.microsoft.com/en-us/library/windows/desktop/dd318936%28v=vs.85%29.aspx]]. Interested developers may be able to use those APIs to provide LazDeviceAPIs functionality.
5761
5862## Roadmap
5963
6064LazDeviceAPIs is currently implemented only for LCL-CustomDrawn-Android
6165
6266## See Also
6367
6468- [[Custom Drawn Interface/Android]]
6569- Talk:LazDeviceAPIs
6670
6771---
6872*From the Free Pascal wiki, page "LazDeviceAPIs", as it stood on 2020-02-18 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*

Back to history