Java 类android.os.Vibrator 实例源码

项目:PWEditText-SafeKeyboard    文件:SafetyKeyboard.java   
private void initParams() {
    mStartX = 0;
    mStartY = 0;
    mKeyWidth = LayoutParams.MATCH_PARENT;
    mKeyHeight = getSaftyKeyHeight() / 15;
    mTitleHeight = getSaftyKeyHeight() / 16;
    mMarginCol = 10;
    mMarginRow = 10;
    mPaddingLeft = 0;
    mPaddingTop = 0;
    mPaddingRight = 0;
    mPaddingBottom = 0;
    mWidth = LayoutParams.MATCH_PARENT;
    mHeight = getSaftyKeyboardHeight();
    try {
        mVibrator = (Vibrator) mContext
                .getSystemService(Context.VIBRATOR_SERVICE);
    } catch (Exception e) {
        e.getStackTrace();
    }
    mAudioManger = (AudioManager) mContext
            .getSystemService(Context.AUDIO_SERVICE);
    mSoundEffect = Settings.System.SOUND_EFFECTS_ENABLED
            .equals("sound_effects_enabled");
    mAdapter = new KeyBoardDataAdapter();
}
项目:lineagex86    文件:SoundSettings.java   
public List<String> getNonIndexableKeys(Context context) {
    final ArrayList<String> rt = new ArrayList<String>();
    if (Utils.isVoiceCapable(context)) {
        rt.add(KEY_NOTIFICATION_VOLUME);
    } else {
        rt.add(KEY_RING_VOLUME);
        rt.add(KEY_PHONE_RINGTONE);
        rt.add(KEY_WIFI_DISPLAY);
        rt.add(KEY_VIBRATE_WHEN_RINGING);
    }
    Vibrator vib = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
    if (vib == null || !vib.hasVibrator()) {
        rt.add(KEY_VIBRATE);
    }
    CMHardwareManager hardware = CMHardwareManager.getInstance(context);
    if (!hardware.isSupported(CMHardwareManager.FEATURE_VIBRATOR)) {
        rt.add(KEY_VIBRATION_INTENSITY);
    }

    return rt;
}
项目:OSchina_resources_android    文件:DatePickerDialog.java   
@SuppressWarnings("WrongConstant")
@Override
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);
    }
}
项目:cniao5    文件:CNiaoApplication.java   
@Override
public void onCreate() {
    super.onCreate();
    mInstance = this;
    // 通过代码注册你的AppKey和AppSecret
    MobSDK.init(this, "201f8a7a91c30", "c63ec5c1eeac1f873ec78c1365120431");

    sContext = getApplicationContext();
    initUser();
    Utils.init(this);

    locationService = new LocationService(getApplicationContext());
    mVibrator =(Vibrator)getApplicationContext().getSystemService(Service.VIBRATOR_SERVICE);

    //配置数据库
    setupDatabase();

}
项目:CustomAndroidOneSheeld    文件:NotificationShield.java   
protected void showNotification(String notificationText) {
    // TODO Auto-generated method stub
    NotificationCompat.Builder build = new NotificationCompat.Builder(
            activity);
    build.setSmallIcon(OneSheeldApplication.getNotificationIcon());
    build.setContentTitle(notificationText);
    build.setContentText(activity.getString(R.string.notifications_notification_received_from_1sheeld));
    build.setTicker(notificationText);
    build.setWhen(System.currentTimeMillis());
    Toast.makeText(activity, notificationText, Toast.LENGTH_SHORT).show();
    Vibrator v = (Vibrator) activity
            .getSystemService(Context.VIBRATOR_SERVICE);
    v.vibrate(1000);
    Intent notificationIntent = new Intent(activity, MainActivity.class);
    notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP
            | Intent.FLAG_ACTIVITY_SINGLE_TOP);
    PendingIntent intent = PendingIntent.getActivity(activity, 0,
            notificationIntent, 0);
    build.setContentIntent(intent);
    Notification notification = build.build();
    NotificationManager notificationManager = (NotificationManager) activity
            .getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.notify(2, notification);
}
项目:PeSanKita-android    文件:IncomingRinger.java   
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private boolean shouldVibrateNew(Context context, int ringerMode) {
    Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);

    if (vibrator == null || !vibrator.hasVibrator()) {
        return false;
    }

    boolean vibrateWhenRinging = Settings.System.getInt(context.getContentResolver(), "vibrate_when_ringing", 0) != 0;

    if (vibrateWhenRinging) {
        return ringerMode != AudioManager.RINGER_MODE_SILENT;
    } else {
        return ringerMode == AudioManager.RINGER_MODE_VIBRATE;
    }
}
项目:BatteryAlert    文件:BatteryReceiver.java   
@Override
public void onReceive(Context context, Intent intent) {
    int alertValue = PreferenceManager.getDefaultSharedPreferences(context).getInt(MainActivity.KEY_BATTERY_PERCENT, 20);

    int status = intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1);
    int plugged = intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1);
    float level = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1);
    float scale = intent.getIntExtra(BatteryManager.EXTRA_SCALE, -1);

    boolean isCharging = status == BatteryManager.BATTERY_STATUS_CHARGING || plugged == BatteryManager.BATTERY_PLUGGED_USB || plugged == BatteryManager.BATTERY_PLUGGED_AC;
    float value = (level * 100f) / scale;

    if (!isCharging && (int) value == alertValue) {
        ((Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE)).vibrate(3000);
        Toast.makeText(context, String.format(context.getString(R.string.msg_low_battery), (int) value), Toast.LENGTH_LONG).show();
    }
}
项目:CustomAndroidOneSheeld    文件:DataLoggerShield.java   
protected void showNotification(String notificationText) {
    // TODO Auto-generated method stub
    NotificationCompat.Builder build = new NotificationCompat.Builder(
            activity);
    build.setSmallIcon(OneSheeldApplication.getNotificationIcon());
    build.setContentTitle(activity.getString(R.string.data_logger_shield_name));
    build.setContentText(notificationText);
    build.setTicker(notificationText);
    build.setWhen(System.currentTimeMillis());
    build.setAutoCancel(true);
    Toast.makeText(activity, notificationText, Toast.LENGTH_SHORT).show();
    Vibrator v = (Vibrator) activity
            .getSystemService(Context.VIBRATOR_SERVICE);
    v.vibrate(1000);
    Intent notificationIntent = new Intent(Intent.ACTION_VIEW);
    MimeTypeMap mimeTypeMap = MimeTypeMap.getSingleton();
    String mimeFileType = mimeTypeMap.getMimeTypeFromExtension("csv");
    if(Build.VERSION.SDK_INT>=24) {
        Uri fileURI = FileProvider.getUriForFile(activity,
                BuildConfig.APPLICATION_ID + ".provider",
                new File(filePath == null || filePath.length() == 0 ? "" : filePath));
        notificationIntent.setDataAndType(fileURI, mimeFileType);
    }
    else{
        notificationIntent.setDataAndType(Uri.fromFile(new File(filePath == null
                || filePath.length() == 0 ? "" : filePath)), mimeFileType);
    }
    notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    notificationIntent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
    PendingIntent intent = PendingIntent.getActivity(activity, 0,
            notificationIntent, 0);
    build.setContentIntent(intent);
    Notification notification = build.build();
    notification.flags |= Notification.FLAG_AUTO_CANCEL;
    NotificationManager notificationManager = (NotificationManager) activity
            .getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.notify((int) new Date().getTime(), notification);
}
项目:Tribe    文件:EaseNotifier.java   
/**
 * this function can be override
 * @param context
 * @return
 */
public EaseNotifier init(Context context){
    appContext = context;
    notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);

    packageName = appContext.getApplicationInfo().packageName;
    if (Locale.getDefault().getLanguage().equals("zh")) {
        msgs = msg_ch;
    } else {
        msgs = msg_eng;
    }

    audioManager = (AudioManager) appContext.getSystemService(Context.AUDIO_SERVICE);
    vibrator = (Vibrator) appContext.getSystemService(Context.VIBRATOR_SERVICE);

    return this;
}
项目:Tribe    文件:EaseNotifier.java   
/**
 * this function can be override
 * @param context
 * @return
 */
public EaseNotifier init(Context context){
    appContext = context;
    notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);

    packageName = appContext.getApplicationInfo().packageName;
    if (Locale.getDefault().getLanguage().equals("zh")) {
        msgs = msg_ch;
    } else {
        msgs = msg_eng;
    }

    audioManager = (AudioManager) appContext.getSystemService(Context.AUDIO_SERVICE);
    vibrator = (Vibrator) appContext.getSystemService(Context.VIBRATOR_SERVICE);

    return this;
}
项目:Bigbang    文件:KeyPressedTipViewController.java   
@Override
public void run() {
    Vibrator vibrator= (Vibrator)mContext.getSystemService(Context.VIBRATOR_SERVICE);
    vibrator.vibrate(10);
    if (currentKeyCode == KeyEvent.KEYCODE_BACK){
        isLongPressedCancel = true;
    }else {
        isLongPressedCancel = false;
    }
    if (currentKeyCode==KeyEvent.KEYCODE_HOME){
        isLongPressedHome = true;
    }
    if (currentKeyCode==KeyEvent.KEYCODE_APP_SWITCH){
        isLongPressedRecent = true;
    }
    KeyPressedTipViewController.getInstance().show(null);
}
项目:GravityBox    文件:RingerModeTile.java   
@Override
public void initPreferences() {
    if (Utils.hasVibrator(mContext)) {
        mHasVibrator = true;
        mVibrator = (Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE);
    }

    Set<String> smodes = mPrefs.getStringSet(
            GravityBoxSettings.PREF_KEY_RINGER_MODE_TILE_MODE,
            new HashSet<String>(Arrays.asList(new String[] { "1", "2", "3" })));
    List<String> lmodes = new ArrayList<String>(smodes);
    Collections.sort(lmodes);
    int modes[] = new int[lmodes.size()];
    for (int i=0; i<lmodes.size(); i++) {
        modes[i] = Integer.valueOf(lmodes.get(i));
    }
    if (DEBUG) log(getKey() + ": onPreferenceInitialize: modes=" + Arrays.toString(modes));
    updateSettings(modes);

    mQuickMode = Utils.isOxygenOs35Rom() ? true :
            mPrefs.getBoolean(GravityBoxSettings.PREF_KEY_RINGER_MODE_TILE_QUICK_MODE, false);

    super.initPreferences();
}
项目:GarageDoor    文件:GarageDoorIntentService.java   
@Override
protected void onHandleIntent(Intent intent) {
    SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);

    // Play a click sound and vibrate quickly
    GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this);
    AudioManager audioManager = (AudioManager)getSystemService(AUDIO_SERVICE);
    audioManager.playSoundEffect(SoundEffectConstants.CLICK, 1.0f);
    Vibrator vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE);
    vibrator.vibrate(VIBRATOR_PULSE);

    try {
        Bundle data = new Bundle();
        data.putString("user",
                sharedPreferences.getString(GarageDoorWidgetProvider.PREF_USERNAME, ""));
        data.putString("password",
                sharedPreferences.getString(GarageDoorWidgetProvider.PREF_PASSWORD, ""));
        data.putString("timestamp", String.valueOf(System.currentTimeMillis() / 1000));

        String id = Integer.toString(getNextMsgId());
        gcm.send(GarageDoorWidgetProvider.GCM_SENDER_ID + "@gcm.googleapis.com",
                id, TIME_TO_LIVE, data);
    } catch (IOException e) {
        Log.e(TAG, "Error sending message", e);
    }
}
项目:appinventor-extensions    文件:Player.java   
/**
 * Creates a new Player component.
 *
 * @param container
 */
public Player(ComponentContainer container) {
  super(container.$form());
  activity = container.$context();
  sourcePath = "";
  vibe = (Vibrator) form.getSystemService(Context.VIBRATOR_SERVICE);
  form.registerForOnDestroy(this);
  form.registerForOnResume(this);
  form.registerForOnPause(this);
  form.registerForOnStop(this);
  // Make volume buttons control media, not ringer.
  form.setVolumeControlStream(AudioManager.STREAM_MUSIC);
  loop = false;
  playOnlyInForeground = false;
  focusOn = false;
  am = (audioFocusSupported) ? FroyoUtil.setAudioManager(activity) : null;
  afChangeListener = (audioFocusSupported) ? FroyoUtil.setAudioFocusChangeListener(this) : null;
}
项目:OneTwo    文件:DiceListAdapter.java   
@Override
public void onClick(View view) {
    Vibrator vibrator = (Vibrator) view.getContext().getSystemService(Context.VIBRATOR_SERVICE);
    long[] pattern = {0,15,10,15,10,15};
    vibrator.vibrate(pattern,-1);
    int pos = getLayoutPosition();  // getAdapterPosition() may return -1 and produce an error
    int max_dice = Integer.parseInt(mFaces.get(pos));
    int new_num = random.nextInt(max_dice) + 1;
    mData.set(pos, String.valueOf(new_num));
    notifyDataSetChanged();
    RollingRunnable rollingRunnable = new RollingRunnable(pos, max_dice);
    handler.postDelayed(rollingRunnable, 50);
    handler.postDelayed(rollingRunnable, 110);
    handler.postDelayed(rollingRunnable, 190);
    handler.postDelayed(rollingRunnable, 280);
    if (random.nextBoolean()){
        handler.postDelayed(rollingRunnable, 500);
    }
}
项目:FastAndroid    文件:BaseCallActivity.java   
public void onIncomingCallRinging() {
    int ringerMode = NotificationUtil.getRingerMode(this);
    if (ringerMode != AudioManager.RINGER_MODE_SILENT) {
        if (ringerMode == AudioManager.RINGER_MODE_VIBRATE) {
            mVibrator = (Vibrator) RongContext.getInstance().getSystemService(Context.VIBRATOR_SERVICE);
            mVibrator.vibrate(new long[]{500, 1000}, 0);
        } else {
            Uri uri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE);
            mMediaPlayer = new MediaPlayer();
            try {
                mMediaPlayer.setDataSource(this, uri);
                mMediaPlayer.setLooping(true);
                mMediaPlayer.prepare();
                mMediaPlayer.start();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
项目:appinventor-extensions    文件:Sound.java   
public Sound(ComponentContainer container) {
  super(container.$form());
  thisComponent = this;
  soundPool = new SoundPool(MAX_STREAMS, AudioManager.STREAM_MUSIC, 0);
  soundMap = new HashMap<String, Integer>();
  vibe = (Vibrator) form.getSystemService(Context.VIBRATOR_SERVICE);
  sourcePath = "";
  loadComplete = true;  //nothing to wait for until we attempt to load
  form.registerForOnResume(this);
  form.registerForOnStop(this);
  form.registerForOnDestroy(this);

  // Make volume buttons control media, not ringer.
  form.setVolumeControlStream(AudioManager.STREAM_MUSIC);

  // Default property values
  MinimumInterval(500);

  if (waitForLoadToComplete) {
    new OnLoadHelper().setOnloadCompleteListener(soundPool);
  }
}
项目:Cable-Android    文件:ConversationActivity.java   
@Override
public void onRecorderCanceled() {
  Vibrator vibrator = (Vibrator)getSystemService(Context.VIBRATOR_SERVICE);
  vibrator.vibrate(50);
  getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

  ListenableFuture<Pair<Uri, Long>> future = audioRecorder.stopRecording();
  future.addListener(new ListenableFuture.Listener<Pair<Uri, Long>>() {
    @Override
    public void onSuccess(final Pair<Uri, Long> result) {
      new AsyncTask<Void, Void, Void>() {
        @Override
        protected Void doInBackground(Void... params) {
          PersistentBlobProvider.getInstance(ConversationActivity.this).delete(result.first);
          return null;
        }
      }.execute();
    }

    @Override
    public void onFailure(ExecutionException e) {}
  });
}
项目:Zxing-Custom    文件:BeepManager.java   
private void playBeepSoundAndVibrateSingle(){
  reset();
  if(playBeep && mediaPlayerSingle!=null){
      mediaPlayerSingle.start();
  }
  if (vibrate) {
    Vibrator vibrator = (Vibrator) activity.getSystemService(Context.VIBRATOR_SERVICE);
    vibrator.vibrate(VIBRATE_DURATION);
  }
}
项目:homescreenarcade    文件:Controls.java   
public Controls(BlockDropWallpaper ga) {
    super(ga);

    lineThresholds = host.getResources().getIntArray(R.array.line_thresholds);
    shortVibeTime = 0;

    v = (Vibrator) host.getSystemService(Context.VIBRATOR_SERVICE);

    buttonVibrationEnabled = PreferenceManager.getDefaultSharedPreferences(host).getBoolean("pref_vibration_button", false);
    eventVibrationEnabled = PreferenceManager.getDefaultSharedPreferences(host).getBoolean("pref_vibration_events", false);
    try {
        vibrationOffset = Integer.parseInt(PreferenceManager.getDefaultSharedPreferences(host).getString("pref_vibDurOffset", "0"));
    } catch(NumberFormatException e) {
        vibrationOffset = 0;
    }
    if(PreferenceManager.getDefaultSharedPreferences(host).getBoolean("pref_accelerationH", true))
        initialHIntervalFactor = 2;
    else
        initialHIntervalFactor = 1;
    if(PreferenceManager.getDefaultSharedPreferences(host).getBoolean("pref_accelerationV", true))
        initialVIntervalFactor = 2;
    else
        initialVIntervalFactor = 1;
    playerSoftDrop = false;
    leftMove = false;
    rightMove = false;
    leftRotation = false;
    rightRotation = false;
    clearLeftMove = false;
    clearRightMove = false;
    clearPlayerSoftDrop = false;
    continuousSoftDrop = false;
    continuousLeftMove = false;
    continuousRightMove = false;
    previewBox = null;
    boardTouched = false;
}
项目:OSchina_resources_android    文件:BeepManager.java   
public synchronized void playBeepSoundAndVibrate() {
    if (playBeep && mediaPlayer != null) {
        mediaPlayer.start();
    }
    if (vibrate) {
        Vibrator vibrator = (Vibrator) activity.getSystemService(Context.VIBRATOR_SERVICE);
        vibrator.vibrate(VIBRATE_DURATION);
    }
}
项目:GitHub    文件:CaptureActivity.java   
private void playBeepSoundAndVibrate() {
    if (playBeep && mediaPlayer != null) {
        mediaPlayer.start();
    }
    if (vibrate) {
        Vibrator vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE);
        vibrator.vibrate(VIBRATE_DURATION);
    }
}
项目:GitHub    文件:DatePickerDialog.java   
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);
    }
}
项目:buildAPKsSamples    文件:GameView.java   
/**
 * Gets the vibrator from the controller if it is present. Note that it
 * would be easy to get the system vibrator here if the controller one
 * is not present, but we don't choose to do it in this case.
 *
 * @return the Vibrator for the controller, or null if it is not
 *         present. or the API level cannot support it
 */
@SuppressLint("NewApi")
private final Vibrator getVibrator() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN &&
            null != mInputDevice) {
        return mInputDevice.getVibrator();
    }
    return null;
}
项目:Zxing-Custom    文件:BeepManager.java   
private void playBeepSoundAndVibrateTriple(){
  reset();
  if(playBeep && mediaPlayerTriple!=null){
    Log.d("CameraActivity", String.format("play sound triple offset %d", mediaPlayerSingle.getCurrentPosition()));
    mediaPlayerTriple.start();
  }
  if (vibrate) {
    Vibrator vibrator = (Vibrator) activity.getSystemService(Context.VIBRATOR_SERVICE);
    vibrator.vibrate(VIBRATE_DURATION_LARGE);
  }
}
项目:Protestr    文件:ShakeToAlertService.java   
private void listenForShakes() {
    final SensorManager sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
    vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
    shakeDetector = new ShakeDetector(this);
    shakeDetector.setSensitivity(sensorSensitivity);
    shakeDetector.start(sensorManager);
}
项目:SmingZZick_App    文件:MusicListenService.java   
@Override
public void handleMessage(Message msg) {
    if (SmingManager.getInstance().isVibrateSongEnd() == true) {
        Vibrator vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
        vibrator.vibrate(SmingManager.getInstance().getVibratePattern(), -1);
    }
}
项目:ZXingDemo    文件:CaptureActivity.java   
private void playBeepSoundAndVibrate() {
    if (playBeep && mediaPlayer != null) {
        mediaPlayer.start();
    }
    if (vibrate) {
        Vibrator vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE);
        vibrator.vibrate(VIBRATE_DURATION);
    }
}
项目:RNLearn_Project1    文件:VibrationModule.java   
@ReactMethod
public void cancel() {
  Vibrator v = (Vibrator) getReactApplicationContext().getSystemService(Context.VIBRATOR_SERVICE);
  if (v != null) {
    v.cancel();
  }
}
项目:keepass2android    文件:BeepManager.java   
synchronized void playBeepSoundAndVibrate() {
  if (playBeep && mediaPlayer != null) {
    mediaPlayer.start();
  }
  if (vibrate) {
    Vibrator vibrator = (Vibrator) activity.getSystemService(Context.VIBRATOR_SERVICE);
    vibrator.vibrate(VIBRATE_DURATION);
  }
}
项目:Zxing    文件:BeepManager.java   
public void playBeepSoundAndVibrate() {
    if (playBeep && mediaPlayer != null) {
        mediaPlayer.start();
    }
    if (vibrate) {
        Vibrator vibrator = (Vibrator) activity.getSystemService(Context.VIBRATOR_SERVICE);
        vibrator.vibrate(VIBRATE_DURATION);
    }
}
项目:CodeScaner    文件:BeepManager.java   
synchronized void playBeepSoundAndVibrate() {
  if (playBeep && mediaPlayer != null) {
    mediaPlayer.start();
  }
  if (vibrate) {
    Vibrator vibrator = (Vibrator) activity.getSystemService(Context.VIBRATOR_SERVICE);
    vibrator.vibrate(VIBRATE_DURATION);
  }
}
项目:Viewshot    文件:MainActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    frameLayout = (FrameLayout) findViewById(R.id.framelayout);
    vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE);
    PermissionRequester permissionRequester = new PermissionRequester(this, this, Manifest.permission.WRITE_EXTERNAL_STORAGE);
    permissionRequester.request();
}
项目:PeSanKita-android    文件:DeviceActivity.java   
@Override
public void onQrDataFound(final String data) {
  Util.runOnMain(new Runnable() {
    @Override
    public void run() {
      ((Vibrator)getSystemService(Context.VIBRATOR_SERVICE)).vibrate(50);
      Uri uri = Uri.parse(data);
      deviceLinkFragment.setLinkClickedListener(uri, DeviceActivity.this);

      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        deviceAddFragment.setSharedElementReturnTransition(TransitionInflater.from(DeviceActivity.this).inflateTransition(R.transition.fragment_shared));
        deviceAddFragment.setExitTransition(TransitionInflater.from(DeviceActivity.this).inflateTransition(android.R.transition.fade));

        deviceLinkFragment.setSharedElementEnterTransition(TransitionInflater.from(DeviceActivity.this).inflateTransition(R.transition.fragment_shared));
        deviceLinkFragment.setEnterTransition(TransitionInflater.from(DeviceActivity.this).inflateTransition(android.R.transition.fade));

        getSupportFragmentManager().beginTransaction()
                                   .addToBackStack(null)
                                   .addSharedElement(deviceAddFragment.getDevicesImage(), "devices")
                                   .replace(android.R.id.content, deviceLinkFragment)
                                   .commit();

      } else {
        getSupportFragmentManager().beginTransaction()
                                   .setCustomAnimations(R.anim.slide_from_bottom, R.anim.slide_to_bottom,
                                                        R.anim.slide_from_bottom, R.anim.slide_to_bottom)
                                   .replace(android.R.id.content, deviceLinkFragment)
                                   .addToBackStack(null)
                                   .commit();
      }
    }
  });
}
项目:boohee_v5.6    文件:TimeLineUtility.java   
public static void copyText(Context context, String post) {
    if (context != null && !TextUtils.isEmpty(post)) {
        try {
            ((Vibrator) context.getSystemService("vibrator")).vibrate(100);
            ((ClipboardManager) context.getSystemService("clipboard")).setPrimaryClip
                    (ClipData.newPlainText(post, post));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
项目:tvConnect_android    文件:BeepManager.java   
public synchronized void playBeepSoundAndVibrate() {
  if (playBeep && mediaPlayer != null) {
    mediaPlayer.start();
  }
  if (vibrate) {
    Vibrator vibrator = (Vibrator) activity.getSystemService(Context.VIBRATOR_SERVICE);
    vibrator.vibrate(VIBRATE_DURATION);
  }
}
项目:RNLearn_Project1    文件:VibrationModule.java   
@ReactMethod
public void cancel() {
  Vibrator v = (Vibrator) getReactApplicationContext().getSystemService(Context.VIBRATOR_SERVICE);
  if (v != null) {
    v.cancel();
  }
}
项目:CustomAndroidOneSheeld    文件:VibrationShield.java   
@Override
public void reset() {
    ((Vibrator)getApplication().getSystemService(Context.VIBRATOR_SERVICE)).cancel();
    if (!scheduledThreadPoolExecutor.isShutdown())
        scheduledThreadPoolExecutor.shutdown();
    futureTasks.clear();
}
项目:Cable-Android    文件:ConversationActivity.java   
@Override
public void onRecorderStarted() {
  Vibrator vibrator = (Vibrator)getSystemService(Context.VIBRATOR_SERVICE);
  vibrator.vibrate(20);
  getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

  audioRecorder.startRecording();
}
项目:boohee_v5.6    文件:ViewTipActivity.java   
private void copyText() {
    try {
        ((Vibrator) getSystemService("vibrator")).vibrate(100);
        ((ClipboardManager) getSystemService("clipboard")).setPrimaryClip(ClipData
                .newPlainText(this.message, this.message));
        Helper.showToast((CharSequence) "已复制到粘贴板");
    } catch (Exception e) {
        e.printStackTrace();
    }
}