Skip to content

Instantly share code, notes, and snippets.

@jamlfy
Last active August 29, 2015 14:16
Show Gist options
  • Select an option

  • Save jamlfy/a2a85ca8b265011213e4 to your computer and use it in GitHub Desktop.

Select an option

Save jamlfy/a2a85ca8b265011213e4 to your computer and use it in GitHub Desktop.
Plugins basics in nativescript
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();
}
}
// 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