Last active
August 29, 2015 14:16
-
-
Save jamlfy/a2a85ca8b265011213e4 to your computer and use it in GitHub Desktop.
Plugins basics in nativescript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package org.nativescript.vibration; | |
| import android.content.Context; | |
| import android.os.Vibrator; | |
| /** | |
| * This class provides access to vibration on the device. | |
| */ | |
| public class Vibration { | |
| /** | |
| * Vibrates the device for a given amount of time. | |
| * | |
| * @param time Time to vibrate in ms. | |
| */ | |
| public void start(long time) { | |
| // Start the vibration, 0 defaults to half a second. | |
| if (time == 0) { | |
| time = 500; | |
| } | |
| Vibrator vibrator = (Vibrator) | |
| vibrator.vibrate(time); | |
| } | |
| /** | |
| * Immediately cancels any currently running vibration. | |
| */ | |
| public void cancel() { | |
| Vibrator vibrator = (Vibrator); | |
| vibrator.cancel(); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Well... | |
| var vibrator = new android.os.Vibrator(); | |
| vibrator.vibrate(1000); | |
| // or | |
| var vibrator = new org.nativescript.vibration(); | |
| vibrator.strat(1000); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment