Java Code Examples for android.os.Vibrator#cancel()

The following examples show how to use android.os.Vibrator#cancel() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HostVibrationProfile.java    From DeviceConnect-Android with MIT License 6 votes vote down vote up
@Override
public boolean onRequest(final Intent request, final Intent response) {
    Vibrator vibrator = (Vibrator) getContext().getSystemService(Context.VIBRATOR_SERVICE);

    if (vibrator == null || !vibrator.hasVibrator()) {
        setResult(response, IntentDConnectMessage.RESULT_ERROR);
    } else {
        vibrator.cancel();
    }

    // cancel()は現在されているの振調パターンの1節しかキャンセルしないので、
    // それ以降の振動パターンの節の再生を防ぐ為に、キャンセルされたことを示す
    // フラグをたてる。
    mIsCancelled = true;

    setResult(response, IntentDConnectMessage.RESULT_OK);
    return true;
}
 
Example 2
Source File: VibrationModule.java    From react-native-GPay with MIT License 5 votes vote down vote up
@ReactMethod
public void cancel() {
  Vibrator v = (Vibrator) getReactApplicationContext().getSystemService(Context.VIBRATOR_SERVICE);
  if (v != null) {
    v.cancel();
  }
}
 
Example 3
Source File: VibrateUtils.java    From AndroidUtilCode with Apache License 2.0 5 votes vote down vote up
/**
 * Cancel vibrate.
 * <p>Must hold {@code <uses-permission android:name="android.permission.VIBRATE" />}</p>
 */
@RequiresPermission(VIBRATE)
public static void cancel() {
    Vibrator vibrator = getVibrator();
    if (vibrator == null) return;
    vibrator.cancel();
}
 
Example 4
Source File: DataLayerListenerService.java    From DeviceConnect-Android with MIT License 5 votes vote down vote up
/**
 * バイブレーションを停止する.
 */
private void stopVibration() {
    Vibrator vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE);
    // 停止のパターンの時にバイブレーションを止めようとした時にcancelが効かないため、
    // バイブレーションが停止している時は、一度バイブレーションを鳴らしたのちに停止を行う。
    vibrator.vibrate(new long[]{100}, -1);
    vibrator.cancel();
}
 
Example 5
Source File: VibrationHandler.java    From PowerSwitch_Android with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Cancels the current vibration
 *
 * @param context any suitable context
 */
public static void cancel(@NonNull Context context) {
    Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
    if (vibrator != null) {
        vibrator.cancel();
    }
}
 
Example 6
Source File: Vibration.java    From redalert-android with Apache License 2.0 5 votes vote down vote up
public static void stopVibration(Context context) {
    // Get vibration service
    Vibrator vibratorService = (Vibrator) context.getSystemService(context.VIBRATOR_SERVICE);

    // Cancel any current vibrations
    vibratorService.cancel();
}
 
Example 7
Source File: ToggleVibratePhone.java    From itracing2 with GNU General Public License v2.0 5 votes vote down vote up
private void stopVibrate(Context context, Intent intent) {
    final Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);

    if (!vibrator.hasVibrator()) {
        Toast.makeText(context, R.string.vibrator_not_found, Toast.LENGTH_LONG).show();
        return;
    }

    vibrator.cancel();

    NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.cancel(ToggleVibratePhone.NOTIFICATION_ID);
    vibrating=false;
}
 
Example 8
Source File: VenvyVibrateUtil.java    From VideoOS-Android-SDK with GNU General Public License v3.0 4 votes vote down vote up
public static void virateCancle(final Context context){
    Vibrator vib = (Vibrator) context.getSystemService(Service.VIBRATOR_SERVICE);
    vib.cancel();
}
 
Example 9
Source File: VibrateUtils.java    From SprintNBA with Apache License 2.0 4 votes vote down vote up
public static void cancel(Context context) {
    Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
    vibrator.cancel();
}
 
Example 10
Source File: Vibration.java    From reacteu-app with MIT License 4 votes vote down vote up
/**
 * Immediately cancels any currently running vibration.
 */
public void cancelVibration() {
    Vibrator vibrator = (Vibrator) this.cordova.getActivity().getSystemService(Context.VIBRATOR_SERVICE);
    vibrator.cancel();
}
 
Example 11
Source File: Vibration.java    From showCaseCordova with Apache License 2.0 4 votes vote down vote up
/**
 * Immediately cancels any currently running vibration.
 */
public void cancelVibration() {
    Vibrator vibrator = (Vibrator) this.cordova.getActivity().getSystemService(Context.VIBRATOR_SERVICE);
    vibrator.cancel();
}
 
Example 12
Source File: Vibration.java    From jpHolo with MIT License 4 votes vote down vote up
/**
 * Immediately cancels any currently running vibration.
 */
public void cancelVibration() {
    Vibrator vibrator = (Vibrator) this.cordova.getActivity().getSystemService(Context.VIBRATOR_SERVICE);
    vibrator.cancel();
}