Yesterday we took a look at the 3D Orientation API from Samsung SDK which was deployed on our latest product, DialerAce 3D. Today we are going to explore the Proximity Sensor API that was also used in the development of DialerAce.
The Proximity Sensor API is available on Samsung SDK 2.0 (or later). The basic function of the API allows an action to be executed when it detects nearby objects.
With this API, we have developed a zoom-in, zoom-out program that displays either of the 2 pictures that is included. When the phone detects an object is close by, the zoomed-in picture will be shown. And if the object is moved away from the phone, the zoomed-out picture will be displayed.
Coding with Proximity API in Samsung SDK
1. Register the proximity handler:
2. Get the Proximity value
g_IsObjectNear = bObjectIsNear;
//app action on object moving nearby
printf(“objects moving nearby \n”);
printf(“object moving away \n”);
//app action on object moving away
With the Proximity API, we can determine whether there is an object near the phone, or if the object is moving away. Callback function will be triggered when an object comes close to the phone or moves away from the phone.
With these values, I have drawn a zoom-out image for when the object is away and a zoom-in image for when the object is close (as seen in the screenshots).
DialerAce: Practical Use
DialerAce uses this proximity feature to call out to the person you have selected in the 3D view – all done without having to touch or press any buttons on the phone.
Simply lock on to the person you want to call (by tilting the phone towards you) and bring the phone to your ear. The proximity sensor, when sensed that your ear is close to the phone, will automatically place the call. It’s just that easy!
Download and Install Samsung SDK 2.1
Samsung SDK 2.1: Click here
Installer cab file for Samsung SDK:
(directory of the SDK)\redist\smi_wm_pro_sdk_redist_2_1_0.cab
Download and Install the Proximity Sensor Sample
To launch the application, move the Proximity_Sensor.exe onto your mobile device and run it through File Manager/Explorer.