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();
}
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();
}
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);
}
}
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;
}
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);
}
Aggregations