ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Mobile specific functions / Sensor functions
  • Use conditions
  • Special cases
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
SensorDetectBeginShake (Function)
In french: CapteurDétecteDébutSecousses
Warning
From version 27, SensorDetectBeginningBumps is kept for backward compatibility. This function is replaced by SensorDetectBeginShake.
Notifies when the device is shaken in any direction.
Example
// Detect shakes
SensorDetectBeginShake("ProcShakeDetection")
// ProcShakeDetection procedure
PROCEDURE ProcShakeDetection()
ToastDisplay("Beginning of shakes")
 
 
// End of shake detection
SensorDetectBeginShake("")
Syntax
<Result> = SensorDetectBeginShake(<WLanguage procedure> [, <Sensitivity> [, <Shake beginning duration> [, <Interval>]]])
<Result>: Boolean
  • True if shake detection was triggered,
  • False otherwise.
<WLanguage procedure>: Procedure name
Name of the WLanguage procedure ("callback") called as soon as the device is shaken. This procedure has the following format :
PROCEDURE <Procedure Name>()
If the procedure name corresponds to an empty string (""), shake detection will be stopped.
<Sensitivity>: Optional integer or optional Integer constant
Indicates the level of sensitivity to shake gestures. Corresponds to:
  • value included between 0 and 2000:
    • 0 for a very high sensitivity to shake gestures,
    • 2000 for a very low sensitivity to shake gestures.
  • one of the following constants:
    snrSensitivityHighHigh sensitivity to shake gestures. Even a low device shaking will trigger the notification.
    snrSensitivityLowLow sensitivity to shake gestures. Only a strong device shaking will trigger the notification.
    snrSensitivityNormal
    (Default value)
    Standard sensitivity to shake gestures
<Shake beginning duration>: Optional integer or optional Duration
Minimum duration (in thousands of a second) during which the device must be shaken before triggering a shake beginning notification. By default, the minimum duration is set to 100 thousands of a second.
This parameter can correspond to:
  • an integer corresponding to the number of thousands of a second,
  • a Duration variable,
  • the duration in a readable format (e.g., 1 s or 10 ms).
<Interval>: Optional integer or optional Duration
Maximum time interval (in thousands of a second) during which the shake gestures can stay below the specified sensitivity level before the shakes are considered as being over. By default, the maximum duration is set to 100 thousands of a second.
This parameter can correspond to:
  • an integer corresponding to the number of thousands of a second,
  • a Duration variable,
  • the duration in a readable format (e.g., 1 s or 10 ms).
Remarks

Use conditions

  • AndroidAndroid Widget This function cannot be used in the emulator or in the simulator. In both cases, the result of the function will always be set to False.
  • iPhone/iPad This function cannot be used in the iOS simulator. In this case, the function result will always correspond to False.
  • The shake detection mechanism uses uses the accelerometer of the device. No shake detection will be performed if the device does not have this sensor. The sensitivity of the detection depends on the quality of the sensor in the device.

Special cases

  • If shake end and beginning detection (triggered by SensorDetectEndShake and SensorDetectBeginShake respectively) take place at the same time, the parameters (<Sensitivity>, <Shake beginning duration> and <Interval>) are the same in both cases. The values taken into account are the ones specified by the function called last.
  • We advise you to stop shake detection when it is no longer required in order to reduce battery consumption. To do so, <WLanguage procedure> must correspond to an empty string ("").
    SensorEnd is used to stop all the current detections.
Component: WDJS.DLL
Minimum version required
  • Version 16
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 05/26/2022

Send a report | Local help