Search in sources :

Example 56 with Vibrator

use of android.os.Vibrator in project coursera-android by aporter.

the class Receiver method onReceive.

@Override
public void onReceive(Context context, Intent intent) {
    Log.i(TAG, "INTENT RECEIVED");
    Vibrator v = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
    v.vibrate(500);
    Toast.makeText(context, "INTENT RECEIVED by Receiver", Toast.LENGTH_LONG).show();
}
Also used : Vibrator(android.os.Vibrator)

Example 57 with Vibrator

use of android.os.Vibrator in project coursera-android by aporter.

the class Receiver method onReceive.

@Override
public void onReceive(Context context, Intent intent) {
    Log.i(TAG, "INTENT RECEIVED");
    Vibrator v = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
    v.vibrate(500);
    Toast.makeText(context, "INTENT RECEIVED by Receiver", Toast.LENGTH_LONG).show();
}
Also used : Vibrator(android.os.Vibrator)

Example 58 with Vibrator

use of android.os.Vibrator in project datetimepicker by flavienlaurent.

the class DatePickerDialog method onCreate.

public void onCreate(Bundle bundle) {
    super.onCreate(bundle);
    Activity activity = getActivity();
    activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
    mVibrator = ((Vibrator) activity.getSystemService("vibrator"));
    if (bundle != null) {
        mCalendar.set(Calendar.YEAR, bundle.getInt(KEY_SELECTED_YEAR));
        mCalendar.set(Calendar.MONTH, bundle.getInt(KEY_SELECTED_MONTH));
        mCalendar.set(Calendar.DAY_OF_MONTH, bundle.getInt(KEY_SELECTED_DAY));
        mVibrate = bundle.getBoolean(KEY_VIBRATE);
    }
}
Also used : Activity(android.app.Activity) Vibrator(android.os.Vibrator)

Example 59 with Vibrator

use of android.os.Vibrator in project Talon-for-Twitter by klinker24.

the class TouchableMovementMethod method onTouchEvent.

@Override
public boolean onTouchEvent(TextView textView, final Spannable spannable, MotionEvent event) {
    if (event.getAction() == MotionEvent.ACTION_DOWN) {
        mPressedSpan = getPressedSpan(textView, spannable, event);
        if (mPressedSpan != null) {
            mPressedSpan.setTouched(true);
            touched = true;
            new Handler().postDelayed(new Runnable() {

                @Override
                public void run() {
                    if (touched && mPressedSpan != null) {
                        Vibrator v = (Vibrator) mPressedSpan.mContext.getSystemService(Context.VIBRATOR_SERVICE);
                        v.vibrate(25);
                        mPressedSpan.onLongClick();
                        mPressedSpan.setTouched(false);
                        mPressedSpan = null;
                        Selection.removeSelection(spannable);
                    }
                }
            }, 500);
            Selection.setSelection(spannable, spannable.getSpanStart(mPressedSpan), spannable.getSpanEnd(mPressedSpan));
        }
    } else if (event.getAction() == MotionEvent.ACTION_MOVE) {
        TouchableSpan touchedSpan = getPressedSpan(textView, spannable, event);
        if (mPressedSpan != null && touchedSpan != mPressedSpan) {
            mPressedSpan.setTouched(false);
            touched = false;
            mPressedSpan = null;
            Selection.removeSelection(spannable);
        }
    } else if (event.getAction() == MotionEvent.ACTION_UP) {
        if (mPressedSpan != null) {
            mPressedSpan.onClick(textView);
            mPressedSpan.setTouched(false);
            mPressedSpan = null;
            Selection.removeSelection(spannable);
        }
    } else {
        if (mPressedSpan != null) {
            mPressedSpan.setTouched(false);
            touched = false;
            super.onTouchEvent(textView, spannable, event);
        }
        mPressedSpan = null;
        Selection.removeSelection(spannable);
    }
    return true;
}
Also used : Handler(android.os.Handler) Vibrator(android.os.Vibrator)

Example 60 with Vibrator

use of android.os.Vibrator in project SwipeBackLayout by ikew0ng.

the class DemoActivity method vibrate.

private void vibrate(long duration) {
    Vibrator vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
    long[] pattern = { 0, duration };
    vibrator.vibrate(pattern, -1);
}
Also used : Vibrator(android.os.Vibrator)

Aggregations

Vibrator (android.os.Vibrator)88 IOException (java.io.IOException)10 RemoteException (android.os.RemoteException)8 SettingNotFoundException (android.provider.Settings.SettingNotFoundException)6 InputDevice (android.view.InputDevice)6 NotificationManager (android.app.NotificationManager)5 Intent (android.content.Intent)5 Bitmap (android.graphics.Bitmap)5 SystemVibrator (android.os.SystemVibrator)5 FileOutputStream (java.io.FileOutputStream)5 Activity (android.app.Activity)4 Context (android.content.Context)4 AudioManager (android.media.AudioManager)4 PowerManager (android.os.PowerManager)4 NotificationCompat (android.support.v4.app.NotificationCompat)4 ErrnoException (android.system.ErrnoException)4 Uri (android.net.Uri)3 AlarmManager (android.app.AlarmManager)2 PendingIntent (android.app.PendingIntent)2 SearchManager (android.app.SearchManager)2