Java Code Examples for android.os.Vibrator

The following are top voted examples for showing how to use android.os.Vibrator. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: PWEditText-SafeKeyboard   File: SafetyKeyboard.java   Source Code and License 6 votes vote down vote up
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();
}
 
Example 2
Project: lineagex86   File: SoundSettings.java   Source Code and License 6 votes vote down vote up
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;
}
 
Example 3
Project: OSchina_resources_android   File: DatePickerDialog.java   Source Code and License 6 votes vote down vote up
@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);
    }
}
 
Example 4
Project: cniao5   File: CNiaoApplication.java   Source Code and License 6 votes vote down vote up
@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();

}
 
Example 5
Project: CustomAndroidOneSheeld   File: NotificationShield.java   Source Code and License 6 votes vote down vote up
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);
}
 
Example 6
Project: PeSanKita-android   File: IncomingRinger.java   Source Code and License 6 votes vote down vote up
@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;
    }
}
 
Example 7
Project: BatteryAlert   File: BatteryReceiver.java   Source Code and License 6 votes vote down vote up
@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();
    }
}
 
Example 8
Project: CustomAndroidOneSheeld   File: DataLoggerShield.java   Source Code and License 6 votes vote down vote up
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);
}
 
Example 9
Project: Tribe   File: EaseNotifier.java   Source Code and License 6 votes vote down vote up
/**
 * 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;
}
 
Example 10
Project: Tribe   File: EaseNotifier.java   Source Code and License 6 votes vote down vote up
/**
 * 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;
}
 
Example 11
Project: Bigbang   File: KeyPressedTipViewController.java   Source Code and License 6 votes vote down vote up
@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);
}
 
Example 12
Project: GravityBox   File: RingerModeTile.java   Source Code and License 6 votes vote down vote up
@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();
}
 
Example 13
Project: GarageDoor   File: GarageDoorIntentService.java   Source Code and License 6 votes vote down vote up
@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);
    }
}
 
Example 14
Project: appinventor-extensions   File: Player.java   Source Code and License 6 votes vote down vote up
/**
 * 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;
}
 
Example 15
Project: OneTwo   File: DiceListAdapter.java   Source Code and License 6 votes vote down vote up
@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);
    }
}
 
Example 16
Project: FastAndroid   File: BaseCallActivity.java   Source Code and License 6 votes vote down vote up
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();
            }
        }
    }
}
 
Example 17
Project: appinventor-extensions   File: Sound.java   Source Code and License 6 votes vote down vote up
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);
  }
}
 
Example 18
Project: Cable-Android   File: ConversationActivity.java   Source Code and License 6 votes vote down vote up
@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) {}
  });
}
 
Example 19
Project: Zxing-Custom   File: BeepManager.java   Source Code and License 5 votes vote down vote up
private void playBeepSoundAndVibrateSingle(){
  reset();
  if(playBeep && mediaPlayerSingle!=null){
      mediaPlayerSingle.start();
  }
  if (vibrate) {
    Vibrator vibrator = (Vibrator) activity.getSystemService(Context.VIBRATOR_SERVICE);
    vibrator.vibrate(VIBRATE_DURATION);
  }
}
 
Example 20
Project: homescreenarcade   File: Controls.java   Source Code and License 5 votes vote down vote up
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;
}
 
Example 21
Project: OSchina_resources_android   File: BeepManager.java   Source Code and License 5 votes vote down vote up
public synchronized void playBeepSoundAndVibrate() {
    if (playBeep && mediaPlayer != null) {
        mediaPlayer.start();
    }
    if (vibrate) {
        Vibrator vibrator = (Vibrator) activity.getSystemService(Context.VIBRATOR_SERVICE);
        vibrator.vibrate(VIBRATE_DURATION);
    }
}
 
Example 22
Project: GitHub   File: CaptureActivity.java   Source Code and License 5 votes vote down vote up
private void playBeepSoundAndVibrate() {
	if (playBeep && mediaPlayer != null) {
		mediaPlayer.start();
	}
	if (vibrate) {
		Vibrator vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE);
		vibrator.vibrate(VIBRATE_DURATION);
	}
}
 
Example 23
Project: GitHub   File: DatePickerDialog.java   Source Code and License 5 votes vote down vote up
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);
	}
}
 
Example 24
Project: buildAPKsSamples   File: GameView.java   Source Code and License 5 votes vote down vote up
/**
 * 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;
}
 
Example 25
Project: Zxing-Custom   File: BeepManager.java   Source Code and License 5 votes vote down vote up
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);
  }
}
 
Example 26
Project: Protestr   File: ShakeToAlertService.java   Source Code and License 5 votes vote down vote up
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);
}
 
Example 27
Project: SmingZZick_App   File: MusicListenService.java   Source Code and License 5 votes vote down vote up
@Override
public void handleMessage(Message msg) {
    if (SmingManager.getInstance().isVibrateSongEnd() == true) {
        Vibrator vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
        vibrator.vibrate(SmingManager.getInstance().getVibratePattern(), -1);
    }
}
 
Example 28
Project: ZXingDemo   File: CaptureActivity.java   Source Code and License 5 votes vote down vote up
private void playBeepSoundAndVibrate() {
	if (playBeep && mediaPlayer != null) {
		mediaPlayer.start();
	}
	if (vibrate) {
		Vibrator vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE);
		vibrator.vibrate(VIBRATE_DURATION);
	}
}
 
Example 29
Project: RNLearn_Project1   File: VibrationModule.java   Source Code and License 5 votes vote down vote up
@ReactMethod
public void cancel() {
  Vibrator v = (Vibrator) getReactApplicationContext().getSystemService(Context.VIBRATOR_SERVICE);
  if (v != null) {
    v.cancel();
  }
}
 
Example 30
Project: keepass2android   File: BeepManager.java   Source Code and License 5 votes vote down vote up
synchronized void playBeepSoundAndVibrate() {
  if (playBeep && mediaPlayer != null) {
    mediaPlayer.start();
  }
  if (vibrate) {
    Vibrator vibrator = (Vibrator) activity.getSystemService(Context.VIBRATOR_SERVICE);
    vibrator.vibrate(VIBRATE_DURATION);
  }
}
 
Example 31
Project: Zxing   File: BeepManager.java   Source Code and License 5 votes vote down vote up
public void playBeepSoundAndVibrate() {
    if (playBeep && mediaPlayer != null) {
        mediaPlayer.start();
    }
    if (vibrate) {
        Vibrator vibrator = (Vibrator) activity.getSystemService(Context.VIBRATOR_SERVICE);
        vibrator.vibrate(VIBRATE_DURATION);
    }
}
 
Example 32
Project: CodeScaner   File: BeepManager.java   Source Code and License 5 votes vote down vote up
synchronized void playBeepSoundAndVibrate() {
  if (playBeep && mediaPlayer != null) {
    mediaPlayer.start();
  }
  if (vibrate) {
    Vibrator vibrator = (Vibrator) activity.getSystemService(Context.VIBRATOR_SERVICE);
    vibrator.vibrate(VIBRATE_DURATION);
  }
}
 
Example 33
Project: Viewshot   File: MainActivity.java   Source Code and License 5 votes vote down vote up
@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();
}
 
Example 34
Project: PeSanKita-android   File: DeviceActivity.java   Source Code and License 5 votes vote down vote up
@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();
      }
    }
  });
}
 
Example 35
Project: boohee_v5.6   File: TimeLineUtility.java   Source Code and License 5 votes vote down vote up
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();
        }
    }
}
 
Example 36
Project: tvConnect_android   File: BeepManager.java   Source Code and License 5 votes vote down vote up
public synchronized void playBeepSoundAndVibrate() {
  if (playBeep && mediaPlayer != null) {
    mediaPlayer.start();
  }
  if (vibrate) {
    Vibrator vibrator = (Vibrator) activity.getSystemService(Context.VIBRATOR_SERVICE);
    vibrator.vibrate(VIBRATE_DURATION);
  }
}
 
Example 37
Project: RNLearn_Project1   File: VibrationModule.java   Source Code and License 5 votes vote down vote up
@ReactMethod
public void cancel() {
  Vibrator v = (Vibrator) getReactApplicationContext().getSystemService(Context.VIBRATOR_SERVICE);
  if (v != null) {
    v.cancel();
  }
}
 
Example 38
Project: CustomAndroidOneSheeld   File: VibrationShield.java   Source Code and License 5 votes vote down vote up
@Override
public void reset() {
    ((Vibrator)getApplication().getSystemService(Context.VIBRATOR_SERVICE)).cancel();
    if (!scheduledThreadPoolExecutor.isShutdown())
        scheduledThreadPoolExecutor.shutdown();
    futureTasks.clear();
}
 
Example 39
Project: Cable-Android   File: ConversationActivity.java   Source Code and License 5 votes vote down vote up
@Override
public void onRecorderStarted() {
  Vibrator vibrator = (Vibrator)getSystemService(Context.VIBRATOR_SERVICE);
  vibrator.vibrate(20);
  getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

  audioRecorder.startRecording();
}
 
Example 40
Project: boohee_v5.6   File: ViewTipActivity.java   Source Code and License 5 votes vote down vote up
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();
    }
}