Example usage for android.content Context VIBRATOR_SERVICE

List of usage examples for android.content Context VIBRATOR_SERVICE

Introduction

In this page you can find the example usage for android.content Context VIBRATOR_SERVICE.

Prototype

String VIBRATOR_SERVICE

To view the source code for android.content Context VIBRATOR_SERVICE.

Click Source Link

Document

Use with #getSystemService(String) to retrieve a android.os.Vibrator for interacting with the vibration hardware.

Usage

From source file:com.cleveroad.audiowidget.AudioWidget.java

@SuppressWarnings("deprecation")
private AudioWidget(@NonNull Builder builder) {
    this.context = builder.context.getApplicationContext();
    this.vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
    this.handler = new Handler();
    this.screenSize = new Point();
    this.removeBounds = new RectF();
    this.hiddenRemWidPos = new Point();
    this.visibleRemWidPos = new Point();
    this.controller = newController();
    this.windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    windowManager.getDefaultDisplay().getSize(screenSize);
    screenSize.y -= statusBarHeight() + navigationBarHeight();

    Configuration configuration = prepareConfiguration(builder);
    playPauseButton = new PlayPauseButton(configuration);
    expandCollapseWidget = new ExpandCollapseWidget(configuration);
    removeWidgetView = new RemoveWidgetView(configuration);
    int offsetCollapsed = context.getResources().getDimensionPixelOffset(R.dimen.aw_edge_offset_collapsed);
    int offsetExpanded = context.getResources().getDimensionPixelOffset(R.dimen.aw_edge_offset_expanded);
    playPauseButtonManager = new TouchManager(playPauseButton,
            playPauseButton.newBoundsChecker(
                    builder.edgeOffsetXCollapsedSet ? builder.edgeOffsetXCollapsed : offsetCollapsed,
                    builder.edgeOffsetYCollapsedSet ? builder.edgeOffsetYCollapsed : offsetCollapsed))
                            .screenWidth(screenSize.x).screenHeight(screenSize.y);
    expandedWidgetManager = new TouchManager(expandCollapseWidget,
            expandCollapseWidget.newBoundsChecker(
                    builder.edgeOffsetXExpandedSet ? builder.edgeOffsetXExpanded : offsetExpanded,
                    builder.edgeOffsetYExpandedSet ? builder.edgeOffsetYExpanded : offsetExpanded))
                            .screenWidth(screenSize.x).screenHeight(screenSize.y);

    playPauseButtonManager.callback(new PlayPauseButtonCallback());
    expandedWidgetManager.callback(new ExpandCollapseWidgetCallback());
    expandCollapseWidget.onWidgetStateChangedListener(new OnWidgetStateChangedListener() {
        @Override/*w  ww .  java  2 s.  c om*/
        public void onWidgetStateChanged(@NonNull State state) {
            if (state == State.COLLAPSED) {
                playPauseButton.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
                try {
                    windowManager.removeView(expandCollapseWidget);
                } catch (IllegalArgumentException e) {
                    // view not attached to window
                }
                playPauseButton.enableProgressChanges(true);
            }
            if (onWidgetStateChangedListener != null) {
                onWidgetStateChangedListener.onWidgetStateChanged(state);
            }
        }

        @Override
        public void onWidgetPositionChanged(int cx, int cy) {

        }
    });
    onControlsClickListener = new OnControlsClickListenerWrapper();
    expandCollapseWidget.onControlsClickListener(onControlsClickListener);
    ppbToExpBoundsChecker = playPauseButton.newBoundsChecker(
            builder.edgeOffsetXExpandedSet ? builder.edgeOffsetXExpanded : offsetExpanded,
            builder.edgeOffsetYExpandedSet ? builder.edgeOffsetYExpanded : offsetExpanded);
    expToPpbBoundsChecker = expandCollapseWidget.newBoundsChecker(
            builder.edgeOffsetXCollapsedSet ? builder.edgeOffsetXCollapsed : offsetCollapsed,
            builder.edgeOffsetYCollapsedSet ? builder.edgeOffsetYCollapsed : offsetCollapsed);
}

From source file:net.reichholf.dreamdroid.activities.VirtualRemoteActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    /* make window full-screen */
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);

    mPrefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
    mEditor = mPrefs.edit();//  w w w .  ja  va  2  s .c o m
    mQuickZap = mPrefs.getBoolean(DreamDroid.PREFS_KEY_QUICKZAP, false);
    mVibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
    reinit();
}

From source file:com.belatrix.events.utils.fcm.EventsFirebaseMessagingService.java

private void sendNotification(String messageTitle, String messageBody) {
    Intent intent = MainActivity.makeIntent(this);
    intent.putExtra(MainActivity.PARAM_FROM_NOTIFICATION, true);
    intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent,
            PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_ONE_SHOT);

    NotificationCompat.BigTextStyle bigTextStyle = new NotificationCompat.BigTextStyle();
    bigTextStyle.setBigContentTitle(messageTitle);
    bigTextStyle.bigText(messageBody);//  w w w .j a  v a  2  s .  c  o m

    Bitmap icon = BitmapFactory.decodeResource(getApplicationContext().getResources(), R.drawable.ic_launcher);

    Uri alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);

    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
            .setSmallIcon(R.drawable.bx_connect_white).setLargeIcon(icon).setStyle(bigTextStyle)
            .setContentText(messageBody).setContentTitle(messageTitle).setAutoCancel(true)
            .setContentIntent(pendingIntent).setSound(alarmSound).setLights(0xFF8F0300, 1000, 200)
            .setPriority(Notification.PRIORITY_MAX);

    //for vibration
    Vibrator v = (Vibrator) getApplicationContext().getSystemService(Context.VIBRATOR_SERVICE);
    v.vibrate(1000);

    NotificationManager notificationManager = (NotificationManager) getSystemService(
            Context.NOTIFICATION_SERVICE);

    long time = new Date().getTime();
    String tmpStr = String.valueOf(time);
    String last4Str = tmpStr.substring(tmpStr.length() - 5);
    int notificationId = Integer.valueOf(last4Str);

    notificationManager.notify(notificationId, notificationBuilder.build());
}

From source file:net.reichholf.dreamdroid.fragment.VirtualRemoteFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    mShouldRetainInstance = false;/*  w ww .j a  v a 2  s  .  c  o  m*/
    super.onCreate(savedInstanceState);
    initTitles(getString(R.string.virtual_remote));

    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActionBarActivity());
    mQuickZap = getArguments().getBoolean(DreamDroid.PREFS_KEY_QUICKZAP,
            prefs.getBoolean(DreamDroid.PREFS_KEY_QUICKZAP, false));
    mSimpleRemote = DreamDroid.getCurrentProfile().isSimpleRemote();
    mVibrator = (Vibrator) getActionBarActivity().getSystemService(Context.VIBRATOR_SERVICE);
    mHandler = new Handler();
}

From source file:it.interfree.leonardoce.bootreceiver.AlarmKlaxon.java

@Override
public void onCreate() {
    mVibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
    // Listen for incoming calls to kill the alarm.
    AlarmAlertWakeLock.acquireCpuWakeLock(this);
}

From source file:org.docrj.smartcard.reader.EmvReadActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.drawer_activity_emv_read);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);//from w w  w  .j a va2  s.c o  m

    DrawerLayout drawerLayout = (DrawerLayout) findViewById(R.id.emv_drawer_layout);
    mNavDrawer = new NavDrawer(this, savedInstanceState, R.id.emv_read, drawerLayout, toolbar);

    ListView listView = (ListView) findViewById(R.id.msg_list);
    ViewSwitcher switcher = (ViewSwitcher) findViewById(R.id.switcher);
    mConsole = new Console(this, savedInstanceState, TEST_MODE_EMV_READ, listView, switcher);
    mNfcManager = new NfcManager(this, this);

    ApduParser.init(this);
    EMVTerminal.loadProperties(getResources());

    // persistent "shared preferences"
    SharedPreferences ss = getSharedPreferences("prefs", Context.MODE_PRIVATE);
    mEditor = ss.edit();

    // persistent settings and settings listener
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    prefs.registerOnSharedPreferenceChangeListener(this);

    mAutoClear = prefs.getBoolean("pref_auto_clear", true);
    mShowMsgSeparators = prefs.getBoolean("pref_show_separators", true);
    String tapFeedback = prefs.getString("pref_tap_feedback", "1");
    mTapFeedback = Integer.valueOf(tapFeedback);

    mVibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
}

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

/**
 * Immediately cancels any currently running vibration.
 *//*from  w  w  w.  j av a2s  . c  o  m*/
public void cancelVibration() {
    Vibrator vibrator = (Vibrator) this.cordova.getActivity().getSystemService(Context.VIBRATOR_SERVICE);
    vibrator.cancel();
}

From source file:com.measurence.sdk.android.gcm_push_notifications.PresenceSessionUpdatesNotificationService.java

private void notifySessionUpdateToUI(String presenceSessionUpdateJson) {
    Intent sessionUpdateNotificationIntent = new Intent(SESSION_UPDATE_INTENT_ID);
    sessionUpdateNotificationIntent.putExtra(SESSION_UPDATE_JSON_PARAMETER, presenceSessionUpdateJson);
    localBroadcastManager.sendBroadcast(sessionUpdateNotificationIntent);
    PresenceSessionUpdate update = PresenceSessionUpdate.fromJson(presenceSessionUpdateJson);
    sendNotification(update.getUserIdentities().get(0).getId(), update.getStoreKey(), update.getStatus());
    Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);

    v.vibrate(2000);/*from w  w w.  ja va2s . c o m*/

    long pattern[] = { 0, 400, 200, 200, 800 };
    // 2nd argument is for repetition pass -1 if you do not want to repeat the Vibrate
    v.vibrate(pattern, -1);
}

From source file:com.suan.weclient.fragment.mass.VoiceFragment.java

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    /*//from   w ww . jav a 2s.com
    init the data
     */
    MainActivity mainActivity = (MainActivity) getActivity();
    mDataManager = ((GlobalContext) mainActivity.getApplicationContext()).getDataManager();
    mFragmentManager = mainActivity.getSupportFragmentManager();

    vibrator = (Vibrator) getActivity().getSystemService(Context.VIBRATOR_SERVICE);
    voiceHandler = new VoiceHandler();

    view = inflater.inflate(R.layout.voice_record_layout, null);
    /*
    fuck android ,you must add the layout params
     */
    ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT);
    view.setLayoutParams(layoutParams);
    initWidgets();
    initListener();

    return view;
}