Example usage for android.os Vibrator cancel

List of usage examples for android.os Vibrator cancel

Introduction

In this page you can find the example usage for android.os Vibrator cancel.

Prototype

@RequiresPermission(android.Manifest.permission.VIBRATE)
public abstract void cancel();

Source Link

Document

Turn the vibrator off.

Usage

From source file:Main.java

public static void cancel(Context context) {
    Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
    vibrator.cancel();
}

From source file:Main.java

public static void vibrate(Context context) {
    Vibrator v = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
    if (v.hasVibrator()) {
        v.cancel();
        v.vibrate(150);//w w w  . j a v a 2s. co  m
    }
}

From source file:Main.java

public static void doVibrate(Context context, int time) {

    Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
    if (vibrator != null) {
        vibrator.cancel();

        vibrator.vibrate(time);/*from  w w w  .ja va  2s  .c o  m*/
    }
}

From source file:Main.java

/**
 * msg shake//from w w w. j av  a2 s .co m
 * 
 * @param context
 * @param isShake
 */
public static void shake(Context context, boolean isShake) {
    Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
    if (vibrator == null) {
        return;
    }
    if (isShake) {
        vibrator.vibrate(SHAKE_PATTERN, -1);
        return;
    }
    vibrator.cancel();
}

From source file:Main.java

/**
 * msg shake//from  w  w w.  j  a  v a2 s . c  om
 * 
 * @param context
 * @param isShake
 */
public static void shakeControlMic(Context context, boolean isShake) {
    Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
    if (vibrator == null) {
        return;
    }
    if (isShake) {
        vibrator.vibrate(SHAKE_MIC_PATTERN, -1);
        return;
    }
    vibrator.cancel();
}

From source file:de.ub0r.android.websms.WebSMSReceiver.java

/**
 * Handle result of message sending.//w ww .j av a2s. c o  m
 *
 * @param context context
 * @param specs   {@link de.ub0r.android.websms.connector.common.ConnectorSpec}
 * @param command {@link de.ub0r.android.websms.connector.common.ConnectorCommand}
 */
static void handleSendCommand(final Context context, final ConnectorSpec specs,
        final ConnectorCommand command) {

    boolean isHandled = false;
    final SharedPreferences p = PreferenceManager.getDefaultSharedPreferences(context);

    if (!specs.hasStatus(ConnectorSpec.STATUS_ERROR)) {
        // Sent successfully
        saveMessage(context, specs, command, MESSAGE_TYPE_SENT);
        if (p.getBoolean(WebSMS.PREFS_SEND_VIBRATE, false)) {
            final Vibrator v = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
            if (v != null) {
                v.vibrate(VIBRATOR_SEND);
                v.cancel();
            }
        }
        isHandled = true;
        messageCompleted(context, command);
    }

    if (!isHandled) {
        // Resend if possible (network might be down temporarily or an odd
        // failure on the provider's web side)
        final int maxResendCount = de.ub0r.android.lib.Utils
                .parseInt(p.getString(WebSMS.PREFS_MAX_RESEND_COUNT, "0"), 0);
        if (maxResendCount > 0) {
            int wasResendCount = command.getResendCount();

            if (wasResendCount < maxResendCount && !isResendCancelled(command.getMsgId())) {

                // schedule resend
                command.setResendCount(wasResendCount + 1);
                displayResendingNotification(context, command);
                scheduleMessageResend(context, specs, command);

                isHandled = true;
            }
        }
    }

    if (!isHandled) {
        // Display notification if sending failed
        displaySendingFailedNotification(context, specs, command);
        messageCompleted(context, command);
    }
}

From source file:jorge.tolentino.empty.Empty.java

/**
 * Immediately cancels any currently running vibration.
 *//* ww  w  . j  a  v a2 s .c  om*/
public void cancelVibration() {
    Vibrator vibrator = (Vibrator) this.cordova.getActivity().getSystemService(Context.VIBRATOR_SERVICE);
    vibrator.cancel();
}

From source file:org.namelessrom.devicecontrol.modules.info.hardware.GpsView.java

public void onResume() {
    final Context context = getContext();
    final boolean location = BaseActivity.isGranted(context, Manifest.permission.ACCESS_COARSE_LOCATION)
            && BaseActivity.isGranted(context, Manifest.permission.ACCESS_FINE_LOCATION);
    if (!location) {
        final Intent intent = new Intent(BaseActivity.ACTION_REQUEST_PERMISSION);
        final ArrayList<String> permissions = new ArrayList<>(2);
        permissions.add(Manifest.permission.ACCESS_COARSE_LOCATION);
        permissions.add(Manifest.permission.ACCESS_FINE_LOCATION);
        intent.putStringArrayListExtra(BaseActivity.EXTRA_PERMISSIONS, permissions);
        LocalBroadcastManager.getInstance(context).sendBroadcast(intent);
    }//from   w  ww .  j a v  a2 s .  com

    addressSubscription = addressObservable.subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<String>() {
                @Override
                public void call(String s) {
                    if (BuildConfig.DEBUG) {
                        final Vibrator vibrator = App.get().getVibrator();
                        vibrator.cancel();
                        vibrator.vibrate(75);
                    }
                    statusView.setText(s);
                }
            }, new ErrorHandler(statusView));
}

From source file:com.mobileman.moments.android.frontend.activity.IncomingCallActivity.java

private void doCleanup() {
    if (delayHandler != null) {
        delayHandler.removeCallbacksAndMessages(null);
    }/*from w  ww  .j  a v  a 2s . c o m*/
    if (mPlayer != null) {
        try {
            mPlayer.stop();
        } catch (IllegalStateException e) {
            // we don't care
        }
        mPlayer.release();
        mPlayer = null;
    }
    streamingUser = null;
    Vibrator vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
    vibrator.cancel();
}

From source file:com.example.bluetooth_faster_connection.MainActivity.java

public void cancel() {
    Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
    v.cancel();
}