AathifMahir.Maui.MauiShakeDetector 0.3.0

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package AathifMahir.Maui.MauiShakeDetector --version 0.3.0                
NuGet\Install-Package AathifMahir.Maui.MauiShakeDetector -Version 0.3.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AathifMahir.Maui.MauiShakeDetector" Version="0.3.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add AathifMahir.Maui.MauiShakeDetector --version 0.3.0                
#r "nuget: AathifMahir.Maui.MauiShakeDetector, 0.3.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install AathifMahir.Maui.MauiShakeDetector as a Cake Addin
#addin nuget:?package=AathifMahir.Maui.MauiShakeDetector&version=0.3.0

// Install AathifMahir.Maui.MauiShakeDetector as a Cake Tool
#tool nuget:?package=AathifMahir.Maui.MauiShakeDetector&version=0.3.0                

Maui Shake Detector

Maui Shake Detector is Shake Event Detector Library Which Detects Shake Event from Android, iOS and etc. with Options to Customize the Shake Gforce and Shake Intervals and Haptics and Haptics Duration and etc.

Permission

In order to use Maui Shake Detector, You need Specific permission for Android

Android

Add the assembly-based permission:

Open the Platforms/Android/MainApplication.cs file and add the following assembly attributes after using directives:

C#


[assembly: UsesPermission(Android.Manifest.Permission.Vibrate)]

  • or -

Update the Android Manifest:

Open the Platforms/Android/AndroidManifest.xml file and add the following in the manifest node:


<uses-permission android:name="android.permission.VIBRATE" />

Get Started

using MauiShakeDetector;

    // Start
    private void BtnStartListening_Clicked(object sender, EventArgs e)
    {
        if (ShakeDetector.Default.IsSupported && !ShakeDetector.Default.IsMonitoring)
        {
            ShakeDetector.Default.StartListening();
            ShakeDetector.Default.ShakeDetected += Detector_ShakeDetected;
            return;
        }
    }

    // Stop
    private void BtnStopListening_Clicked(object sender, EventArgs e)
    {
        if (ShakeDetector.Default.IsMonitoring)
        {
            ShakeDetector.Default.StopListening();
            ShakeDetector.Default.ShakeDetected -= Detector_ShakeDetected;
        }
    }

    private void Detector_ShakeDetected(object sender, ShakeDetectedEventArgs e)
    {
        Debug.Writeline($"No of Shakes : {e.NoOfShakes}");
    }

Parameters

Parameters Type Description
IsSupported bool Indicating Whether ShakeDetector is Supported on this Device
IsMonitoring bool Indicating Whether ShakeDetector is Already Monitoring
IsHapticsSupported bool Indicating Whether Haptics Supported in this Device
IsHapticsEnabled bool Get or Set the Value Indicating Whether Haptics is Enabled or Not
ShakeThresholdGravity double Get or Set the Value of Shake Detection Threshold
ShakeIntervalInMilliseconds TimeSpan Get or Set the value of Minimum Delay betweem Shakes
ShakeResetIntervalInMilliseconds TimeSpan Get or Set the Value of Shake Reset Interval in Milliseconds
MinimumShakeCount int Get or Set the Value for Number of Shakes Required Before Shake is Triggered
AutoStopAfterNoShakes int Gets or sets the value of Auto Stop listening to shake event after number of shakes triggered
HapticsDurationInMilliseconds TimeSpan Get or Set the Value Of Haptics Duration
ShakeDetected event Shake Detected Event for Detecting Whether User Shaked the Device
StartListening() method Start listening for Shake Event
SensorSpeed enum Set the value for Shake Detection Speed When Using Start Listning Method
StopListening() method Stop Already Monitoring Shake Event

License

Maui Shake Detector is Licensed Under MIT License.

Product Compatible and additional computed target framework versions.
.NET net6.0-android31.0 is compatible.  net6.0-ios16.1 is compatible.  net6.0-maccatalyst16.1 is compatible.  net6.0-windows10.0.19041 is compatible.  net7.0 is compatible.  net7.0-android was computed.  net7.0-android33.0 is compatible.  net7.0-ios was computed.  net7.0-ios16.1 is compatible.  net7.0-maccatalyst was computed.  net7.0-maccatalyst16.1 is compatible.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net7.0-windows10.0.19041 is compatible.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.0.0 324 11/19/2023
1.0.0 161 9/13/2023
0.4.0 184 6/3/2023
0.3.0 172 5/24/2023
0.2.0 155 5/19/2023
0.1.0 161 5/15/2023
0.1.0-preview1 123 5/13/2023

v0.3.0
• Added .Net 6 Support

v0.2.0
• Added New Property to Auto Stop Listening to Shake Event "AutoStopAfterNoShakes"
• Enhancements for Comments

v0.1.0
• First Stable Build
• Enhancements for Comments

v0.1.0-preview1
• First Preview Build