android.os.Vibrator Java Examples

The following examples show how to use android.os.Vibrator. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: TelePlus-Android   Author: TelePlusDev   File: LoginActivity.java    License: GNU General Public License v2.0 6 votes vote down vote up
private void onPasscodeError(boolean clear)
{
    if (getParentActivity() == null)
    {
        return;
    }
    Vibrator v = (Vibrator) getParentActivity().getSystemService(Context.VIBRATOR_SERVICE);
    if (v != null)
    {
        v.vibrate(200);
    }
    if (clear)
    {
        codeField.setText("");
    }
    AndroidUtilities.shakeView(confirmTextView, 2, 0);
}
 
Example #2
Source Project: toothpick   Author: stephanenicolas   File: SmoothieApplicationModule.java    License: Apache License 2.0 6 votes vote down vote up
private void bindSystemServices(Application application) {
  bindSystemService(application, LocationManager.class, LOCATION_SERVICE);
  bindSystemService(application, WindowManager.class, WINDOW_SERVICE);
  bindSystemService(application, ActivityManager.class, ACTIVITY_SERVICE);
  bindSystemService(application, PowerManager.class, POWER_SERVICE);
  bindSystemService(application, AlarmManager.class, ALARM_SERVICE);
  bindSystemService(application, NotificationManager.class, NOTIFICATION_SERVICE);
  bindSystemService(application, KeyguardManager.class, KEYGUARD_SERVICE);
  bindSystemService(application, Vibrator.class, VIBRATOR_SERVICE);
  bindSystemService(application, ConnectivityManager.class, CONNECTIVITY_SERVICE);
  bindSystemService(application, WifiManager.class, WIFI_SERVICE);
  bindSystemService(application, InputMethodManager.class, INPUT_METHOD_SERVICE);
  bindSystemService(application, SearchManager.class, SEARCH_SERVICE);
  bindSystemService(application, SensorManager.class, SENSOR_SERVICE);
  bindSystemService(application, TelephonyManager.class, TELEPHONY_SERVICE);
  bindSystemService(application, AudioManager.class, AUDIO_SERVICE);
  bindSystemService(application, DownloadManager.class, DOWNLOAD_SERVICE);
  bindSystemService(application, ClipboardManager.class, CLIPBOARD_SERVICE);
}
 
Example #3
Source Project: coursera-android   Author: aporter   File: Receiver1.java    License: MIT License 6 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent) {

	Log.i(TAG, "INTENT RECEIVED");

	if (isOrderedBroadcast()) {
		Log.i(TAG, "Calling abortBroadcast()");
		abortBroadcast();
	}
	
	Vibrator v = (Vibrator) context
			.getSystemService(Context.VIBRATOR_SERVICE);
	v.vibrate(500);

	Toast.makeText(context, "INTENT RECEIVED by Receiver1",
			Toast.LENGTH_LONG).show();
}
 
Example #4
Source Project: fastnfitness   Author: brodeurlv   File: AlarmReceiver.java    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void onReceive(Context context, Intent arg1) {
    long[] pattern = {
        0,  // Start immediately
        500, 500, 500, 500, 500};
    Vibrator v = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
    // Vibrate for 500 milliseconds
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        v.vibrate(VibrationEffect.createWaveform(pattern, -1));
    } else {
        //deprecated in API 26
        if (v != null) {
            v.vibrate(pattern, -1);
        }
    }
}
 
Example #5
Source Project: enjoyshop   Author: gaolhjy   File: EnjoyshopApplication.java    License: Apache License 2.0 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);

    setDatabase();

}
 
Example #6
Source Project: timecat   Author: triline3   File: ForceTouchListener.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Handle progressive pressure on the screen
 */
private void progressiveForceTouch(){
    runnable = new Runnable() {
        @Override
        public void run() {
            if(getPressure() >= pressureLimit && !alreadyExecuted && isProgressive) {
                if(isVibrate) {
                    Vibrator vibr = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
                    vibr.vibrate(millisToVibrate);
                }
                forceTouchExecution.onForceTouch();
                alreadyExecuted = true;
            }
        }
    };
    timer.scheduleAtFixedRate(runnable, 1);
}
 
Example #7
Source Project: alpha-wallet-android   Author: AlphaWallet   File: FunctionButtonBar.java    License: MIT License 6 votes vote down vote up
@Override
public void onLongTokenClick(View view, Token token, List<BigInteger> tokenIds) {
    //show radio buttons of all token groups
    if (adapter != null) adapter.setRadioButtons(true);

    selection = tokenIds;
    Vibrator vb = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
    if (vb != null && vb.hasVibrator()) {
        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
            VibrationEffect vibe = VibrationEffect.createOneShot(200, DEFAULT_AMPLITUDE);
            vb.vibrate(vibe);
        } else {
            //noinspection deprecation
            vb.vibrate(200);
        }
    }

    //Wait for availability to complete
    waitForMapBuild();

    populateButtons(token, getSelectedTokenId(tokenIds));
    showButtons();
}
 
Example #8
Source Project: BaldPhone   Author: UriahShaulMandel   File: BaldConstraintLayoutButton.java    License: Apache License 2.0 6 votes vote down vote up
@SuppressLint("ClickableViewAccessibility")
public BaldConstraintLayoutButton(Context context) {
    super(context);
    this.sharedPreferences = context.getSharedPreferences(D.BALD_PREFS, Context.MODE_PRIVATE);
    this.longPresses = sharedPreferences.getBoolean(BPrefs.LONG_PRESSES_KEY, BPrefs.LONG_PRESSES_DEFAULT_VALUE);
    this.longPressesShorter = sharedPreferences.getBoolean(BPrefs.LONG_PRESSES_SHORTER_KEY, BPrefs.LONG_PRESSES_SHORTER_DEFAULT_VALUE);
    this.vibrationFeedback = sharedPreferences.getBoolean(BPrefs.VIBRATION_FEEDBACK_KEY, BPrefs.VIBRATION_FEEDBACK_DEFAULT_VALUE);
    this.vibrator = this.vibrationFeedback ? (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE) : null;
    longer = longPresses ? BaldToast.from(context).setText(context.getText(R.string.press_longer)).setType(BaldToast.TYPE_DEFAULT).setLength(0).build() : null;
    if (longPresses)
        if (longPressesShorter) {
            baldButtonTouchListener = new BaldButtonTouchListener(this);
            super.setOnTouchListener(baldButtonTouchListener);
            super.setOnClickListener(D.EMPTY_CLICK_LISTENER);
        } else {
            super.setOnLongClickListener(this);
            super.setOnClickListener(this);
        }
    else
        super.setOnClickListener(this);

}
 
Example #9
Source Project: BaldPhone   Author: UriahShaulMandel   File: BaldLinearLayoutButton.java    License: Apache License 2.0 6 votes vote down vote up
public BaldLinearLayoutButton(Context context) {
    super(context);
    this.sharedPreferences = context.getSharedPreferences(D.BALD_PREFS, Context.MODE_PRIVATE);
    this.longPresses = sharedPreferences.getBoolean(BPrefs.LONG_PRESSES_KEY, BPrefs.LONG_PRESSES_DEFAULT_VALUE);
    this.longPressesShorter = sharedPreferences.getBoolean(BPrefs.LONG_PRESSES_SHORTER_KEY, BPrefs.LONG_PRESSES_SHORTER_DEFAULT_VALUE);
    this.vibrationFeedback = sharedPreferences.getBoolean(BPrefs.VIBRATION_FEEDBACK_KEY, BPrefs.VIBRATION_FEEDBACK_DEFAULT_VALUE);
    this.vibrator = this.vibrationFeedback ? (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE) : null;
    longer = longPresses ? BaldToast.from(context).setText(context.getText(R.string.press_longer)).setType(BaldToast.TYPE_DEFAULT).setLength(0).build() : null;
    if (longPresses)
        if (longPressesShorter) {
            baldButtonTouchListener = new BaldButtonTouchListener(this);
            super.setOnTouchListener(baldButtonTouchListener);
            super.setOnClickListener(D.EMPTY_CLICK_LISTENER);
        } else {
            super.setOnLongClickListener(this);
            super.setOnClickListener(this);
        }
    else
        super.setOnClickListener(this);

}
 
Example #10
Source Project: OsmGo   Author: DoFabien   File: Haptics.java    License: MIT License 6 votes vote down vote up
@PluginMethod()
@SuppressWarnings("MissingPermission")
public void vibrate(PluginCall call) {
  Context c = this.getContext();
  int duration = call.getInt("duration", 300);

  if(!hasPermission(Manifest.permission.VIBRATE)) {
    call.error("Can't vibrate: Missing VIBRATE permission in AndroidManifest.xml");
    return;
  }

  if (Build.VERSION.SDK_INT >= 26) {
    ((Vibrator) c.getSystemService(Context.VIBRATOR_SERVICE)).vibrate(VibrationEffect.createOneShot(duration, VibrationEffect.DEFAULT_AMPLITUDE));
  } else {
    vibratePre26(duration);
  }

  call.success();
}
 
Example #11
Source Project: BaldPhone   Author: UriahShaulMandel   File: BaldLinearLayoutButton.java    License: Apache License 2.0 6 votes vote down vote up
public BaldLinearLayoutButton(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    super(context, attrs, defStyleAttr, defStyleRes);
    this.sharedPreferences = context.getSharedPreferences(D.BALD_PREFS, Context.MODE_PRIVATE);
    this.longPresses = sharedPreferences.getBoolean(BPrefs.LONG_PRESSES_KEY, BPrefs.LONG_PRESSES_DEFAULT_VALUE);
    this.longPressesShorter = sharedPreferences.getBoolean(BPrefs.LONG_PRESSES_SHORTER_KEY, BPrefs.LONG_PRESSES_SHORTER_DEFAULT_VALUE);
    this.vibrationFeedback = sharedPreferences.getBoolean(BPrefs.VIBRATION_FEEDBACK_KEY, BPrefs.VIBRATION_FEEDBACK_DEFAULT_VALUE);
    this.vibrator = this.vibrationFeedback ? (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE) : null;
    longer = longPresses ? BaldToast.from(context).setText(context.getText(R.string.press_longer)).setType(BaldToast.TYPE_DEFAULT).setLength(0).build() : null;
    if (longPresses)
        if (longPressesShorter) {
            baldButtonTouchListener = new BaldButtonTouchListener(this);
            super.setOnTouchListener(baldButtonTouchListener);
            super.setOnClickListener(D.EMPTY_CLICK_LISTENER);
        } else {
            super.setOnLongClickListener(this);
            super.setOnClickListener(this);
        }
    else
        super.setOnClickListener(this);
}
 
Example #12
Source Project: BaldPhone   Author: UriahShaulMandel   File: BaldButton.java    License: Apache License 2.0 6 votes vote down vote up
public BaldButton(Context context, @Nullable AttributeSet attrs) {
    super(context, attrs);
    this.sharedPreferences = context.getSharedPreferences(D.BALD_PREFS, Context.MODE_PRIVATE);
    this.longPresses = sharedPreferences.getBoolean(BPrefs.LONG_PRESSES_KEY, BPrefs.LONG_PRESSES_DEFAULT_VALUE);
    this.longPressesShorter = sharedPreferences.getBoolean(BPrefs.LONG_PRESSES_SHORTER_KEY, BPrefs.LONG_PRESSES_SHORTER_DEFAULT_VALUE);
    this.vibrationFeedback = sharedPreferences.getBoolean(BPrefs.VIBRATION_FEEDBACK_KEY, BPrefs.VIBRATION_FEEDBACK_DEFAULT_VALUE);
    this.vibrator = this.vibrationFeedback ? (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE) : null;
    longer = longPresses ? BaldToast.from(context).setText(context.getText(R.string.press_longer)).setType(BaldToast.TYPE_DEFAULT).setLength(0).build() : null;
    if (longPresses)
        if (longPressesShorter) {
            baldButtonTouchListener = new BaldButtonTouchListener(this);
            super.setOnTouchListener(baldButtonTouchListener);
            super.setOnClickListener(D.EMPTY_CLICK_LISTENER);
        } else {
            super.setOnLongClickListener(this);
            super.setOnClickListener(this);
        }
    else
        super.setOnClickListener(this);
}
 
Example #13
Source Project: ESeal   Author: agenthun   File: App.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    mApplicationContext = this;

    /***
     * 初始化版本升级模块
     */
    UpdateConfig.initGet(this);

    /***
     * 初始化定位sdk,建议在Application中创建
     */
    locationService = new LocationService(getApplicationContext());
    mVibrator = (Vibrator) getApplicationContext().getSystemService(VIBRATOR_SERVICE);
    SDKInitializer.initialize(getApplicationContext());
}
 
Example #14
Source Project: bitmask_android   Author: leapcode   File: EipFragment.java    License: GNU General Public License v3.0 6 votes vote down vote up
private void showToast(Activity activity, String message, boolean vibrateLong) {
    LayoutInflater inflater = getLayoutInflater();
    View layout = inflater.inflate(R.layout.custom_toast,
            activity.findViewById(R.id.custom_toast_container));

    TextView text = layout.findViewById(R.id.text);
    text.setText(message);

    Vibrator v = (Vibrator) activity.getSystemService(Context.VIBRATOR_SERVICE);
    if (vibrateLong) {
        v.vibrate(100);
        v.vibrate(200);
    } else {
        v.vibrate(100);
    }

    Toast toast = new Toast(activity.getApplicationContext());
    toast.setGravity(Gravity.BOTTOM, 0, convertDimensionToPx(this.getContext(), R.dimen.stdpadding));
    toast.setDuration(Toast.LENGTH_LONG);
    toast.setView(layout);
    toast.show();
}
 
Example #15
Source Project: Jreader   Author: Focfa   File: MyGridView.java    License: GNU General Public License v2.0 5 votes vote down vote up
public MyGridView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    mVibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
    mWindowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    mStatusHeight = getStatusHeight(context);
    background = BitmapFactory.decodeResource(getResources(),
            R.drawable.bookshelf_layer_center1);
    if(!mNumColumnsSet){
        mNumColumns = AUTO_FIT;
    }
    mcontext = context;
    setOnItemLongClickListener(this);
}
 
Example #16
Source Project: goprohero   Author: KonradIT   File: MainActivity.java    License: MIT License 5 votes vote down vote up
public void sendModeVideoVideoPhoto(View view) {
	Vibrator v = (Vibrator)getSystemService(VIBRATOR_SERVICE);
       v.vibrate(80);
	Toast.makeText(getApplicationContext(), 
               "Video plus photo!", Toast.LENGTH_SHORT).show();
	new HttpAsyncTask().execute("http://10.5.5.9/gp/gpControl/setting/68/2");
}
 
Example #17
Source Project: Telegram-FOSS   Author: Telegram-FOSS-Team   File: ChatEditTypeActivity.java    License: GNU General Public License v2.0 5 votes vote down vote up
private boolean trySetUsername() {
    if (getParentActivity() == null) {
        return false;
    }
    if (!isPrivate && ((currentChat.username == null && usernameTextView.length() != 0) || (currentChat.username != null && !currentChat.username.equalsIgnoreCase(usernameTextView.getText().toString())))) {
        if (usernameTextView.length() != 0 && !lastNameAvailable) {
            Vibrator v = (Vibrator) getParentActivity().getSystemService(Context.VIBRATOR_SERVICE);
            if (v != null) {
                v.vibrate(200);
            }
            AndroidUtilities.shakeView(checkTextView, 2, 0);
            return false;
        }
    }

    String oldUserName = currentChat.username != null ? currentChat.username : "";
    String newUserName = isPrivate ? "" : usernameTextView.getText().toString();
    if (!oldUserName.equals(newUserName)) {
        if (!ChatObject.isChannel(currentChat)) {
            getMessagesController().convertToMegaGroup(getParentActivity(), chatId, this, param -> {
                if (param != 0) {
                    chatId = param;
                    currentChat = getMessagesController().getChat(param);
                    processDone();
                }
            });
            return false;
        } else {
            getMessagesController().updateChannelUserName(chatId, newUserName);
            currentChat.username = newUserName;
        }
    }
    return true;
}
 
Example #18
Source Project: coursera-android   Author: aporter   File: Receiver2.java    License: MIT License 5 votes vote down vote up
@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 Receiver2", Toast.LENGTH_LONG).show();
}
 
Example #19
Source Project: goprohero   Author: KonradIT   File: MainActivity.java    License: MIT License 5 votes vote down vote up
public void sendIndoorProfile(View view) {
    Vibrator v = (Vibrator)getSystemService(VIBRATOR_SERVICE);
    v.vibrate(400);
    Toast.makeText(getApplicationContext(),
            "Be A HERO", Toast.LENGTH_SHORT).show();
    new HttpAsyncTask().execute("http://10.5.5.9/gp/gpControl/setting/2/9");
    new HttpAsyncTask().execute("http://10.5.5.9/gp/gpControl/setting/3/8");
    new HttpAsyncTask().execute("http://10.5.5.9/gp/gpControl/setting/4/0");
    new HttpAsyncTask().execute("http://10.5.5.9/gp/gpControl/setting/10/0");
}
 
Example #20
Source Project: goprohero   Author: KonradIT   File: MainActivity.java    License: MIT License 5 votes vote down vote up
public void sendVR27K(View view) {
    Vibrator v = (Vibrator)getSystemService(VIBRATOR_SERVICE);
    v.vibrate(80);
    Toast.makeText(getApplicationContext(),
            "2.7K!", Toast.LENGTH_SHORT).show();
    new HttpAsyncTask().execute("http://10.5.5.9/gp/gpControl/setting/2/4");
}
 
Example #21
Source Project: Android-AlarmManagerClock   Author: loonggg   File: ClockAlarmActivity.java    License: Apache License 2.0 5 votes vote down vote up
private void showDialogInBroadcastReceiver(String message, final int flag) {
    if (flag == 1 || flag == 2) {
        mediaPlayer = MediaPlayer.create(this, R.raw.in_call_alarm);
        mediaPlayer.setLooping(true);
        mediaPlayer.start();
    }
    //数组参数意义:第一个参数为等待指定时间后开始震动,震动时间为第二个参数。后边的参数依次为等待震动和震动的时间
    //第二个参数为重复次数,-1为不重复,0为一直震动
    if (flag == 0 || flag == 2) {
        vibrator = (Vibrator) this.getSystemService(Service.VIBRATOR_SERVICE);
        vibrator.vibrate(new long[]{100, 10, 100, 600}, 0);
    }

    final SimpleDialog dialog = new SimpleDialog(this, R.style.Theme_dialog);
    dialog.show();
    dialog.setTitle("闹钟提醒");
    dialog.setMessage(message);
    dialog.setClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (dialog.bt_confirm == v || dialog.bt_cancel == v) {
                if (flag == 1 || flag == 2) {
                    mediaPlayer.stop();
                    mediaPlayer.release();
                }
                if (flag == 0 || flag == 2) {
                    vibrator.cancel();
                }
                dialog.dismiss();
                finish();
            }
        }
    });


}
 
Example #22
Source Project: Huochexing12306   Author: SShineTeam   File: AntiTheftService.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {
	super.onCreate();
	mVibrator = (Vibrator) getApplicationContext().getSystemService(
			VIBRATOR_SERVICE);
	mAM = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
	mMaxVolume = mAM.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
}
 
Example #23
Source Project: homescreenarcade   Author: StringMon   File: Controls.java    License: GNU General Public License v3.0 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 #24
Source Project: AndroidFrame   Author: DaleSmith   File: ShakeByShakeActivity.java    License: Apache License 2.0 5 votes vote down vote up
protected void initView() {
//初始化SoundPool
        mSoundPool = new SoundPool(1, AudioManager.STREAM_SYSTEM, 5);
        mWeiChatAudio = mSoundPool.load(this, R.raw.shake_sound, 1);

//获取Vibrator震动服务
        mVibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE);

    }
 
Example #25
Source Project: goprohero   Author: KonradIT   File: MainActivity.java    License: MIT License 5 votes vote down vote up
public void sendETNI2(View view) {
    Vibrator v = (Vibrator)getSystemService(VIBRATOR_SERVICE);
    v.vibrate(80);
    Toast.makeText(getApplicationContext(),
            "2sec", Toast.LENGTH_SHORT).show();
    new HttpAsyncTask().execute("http://10.5.5.9/gp/gpControl/setting/31/1");
}
 
Example #26
Source Project: android_9.0.0_r45   Author: lulululbj   File: VibratorService.java    License: Apache License 2.0 5 votes vote down vote up
private int getCurrentIntensityLocked(Vibration vib) {
    if (vib.isNotification() || vib.isRingtone()){
        return mNotificationIntensity;
    } else if (vib.isHapticFeedback()) {
        return mHapticFeedbackIntensity;
    } else {
        return Vibrator.VIBRATION_INTENSITY_MEDIUM;
    }
}
 
Example #27
Source Project: goprohero   Author: KonradIT   File: OldCamActivity.java    License: MIT License 5 votes vote down vote up
public void sendNarrowFOV(View view) {
    Vibrator v = (Vibrator)getSystemService(VIBRATOR_SERVICE);
    v.vibrate(80);
    Toast.makeText(getApplicationContext(),
            "Narrow", Toast.LENGTH_SHORT).show();
    String yourFilePath = this.getFilesDir() + "/" + "camconfig.txt";

    File yourFile = new File( yourFilePath );
    try {
        String password = getFileContents(yourFile);
        new HttpAsyncTask ().execute("http://10.5.5.9/camera/FV?t=" + password + "&p=%02");
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
Example #28
Source Project: Telegram   Author: DrKLO   File: TwoStepVerificationSetupActivity.java    License: GNU General Public License v2.0 5 votes vote down vote up
private void onFieldError(TextView field, boolean clear) {
    if (getParentActivity() == null) {
        return;
    }
    Vibrator v = (Vibrator) getParentActivity().getSystemService(Context.VIBRATOR_SERVICE);
    if (v != null) {
        v.vibrate(200);
    }
    if (clear) {
        field.setText("");
    }
    AndroidUtilities.shakeView(field, 2, 0);
}
 
Example #29
Source Project: goprohero   Author: KonradIT   File: MainActivity.java    License: MIT License 5 votes vote down vote up
public void sendETNP5(View view) {
	Vibrator v = (Vibrator)getSystemService(VIBRATOR_SERVICE);
    v.vibrate(80);
	Toast.makeText(getApplicationContext(), 
            "5sec", Toast.LENGTH_SHORT).show();
	new HttpAsyncTask().execute("http://10.5.5.9/gp/gpControl/setting/19/2");
}
 
Example #30
Source Project: android_9.0.0_r45   Author: lulululbj   File: InputDevice.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Gets the vibrator service associated with the device, if there is one.
 * Even if the device does not have a vibrator, the result is never null.
 * Use {@link Vibrator#hasVibrator} to determine whether a vibrator is
 * present.
 *
 * Note that the vibrator associated with the device may be different from
 * the system vibrator.  To obtain an instance of the system vibrator instead, call
 * {@link Context#getSystemService} with {@link Context#VIBRATOR_SERVICE} as argument.
 *
 * @return The vibrator service associated with the device, never null.
 */
public Vibrator getVibrator() {
    synchronized (mMotionRanges) {
        if (mVibrator == null) {
            if (mHasVibrator) {
                mVibrator = InputManager.getInstance().getInputDeviceVibrator(mId);
            } else {
                mVibrator = NullVibrator.getInstance();
            }
        }
        return mVibrator;
    }
}