List of usage examples for android.os Vibrator vibrate
@RequiresPermission(android.Manifest.permission.VIBRATE) public void vibrate(VibrationEffect vibe)
From source file:mai.whack.StickyNotesActivity.java
private void openBrowser(String url) { if (!url.startsWith("http://") && !url.startsWith("https://")) { url = "http://" + url; }/*from w ww . java2s . co m*/ Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); v.vibrate(300); Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); startActivity(browserIntent); }
From source file:com.iss.android.wearable.datalayer.MainActivity.java
private void displaySWBatteryWarning() { // Display a cancelable warning that the HRM battery is running low. AlertDialog.Builder builder = new AlertDialog.Builder(this); String warning = "The Smartwatch battery charge is below 75%. Please charge it to ensure it lasts the night."; Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); v.vibrate(100); builder.setMessage(warning).setTitle(R.string.battery_warning_title).setCancelable(true) .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.cancel();//from w ww . j av a2 s. c om } }); AlertDialog dialog = builder.create(); dialog.show(); }
From source file:com.xortech.multipanic.PanicAddUpdate.java
/** * METHOD TO HANDLE INVALID USER INPUT - VIBRATE AND SHAKE * *//*from w w w.java2s. co m*/ public void VibrateError(EditText mEditText, EditText nEditText, EditText oEditText) { Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); v.vibrate(500); Animation shake = AnimationUtils.loadAnimation(getBaseContext(), R.anim.shake); mEditText.startAnimation(shake); nEditText.startAnimation(shake); oEditText.startAnimation(shake); }
From source file:com.android2.calculator3.EventListener.java
private void vibrate() { if (CalculatorSettings.vibrateOnPress(mContext)) { Vibrator vi = (Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE); if (!vi.hasVibrator()) return; vi.vibrate(CalculatorSettings.getVibrationStrength()); }//w w w .j ava2s .c o m }
From source file:se.droidgiro.scanner.CaptureActivity.java
private void playBeepSoundAndVibrate() { if (playBeep && mediaPlayer != null) { mediaPlayer.start();//from w w w . ja v a2 s. c o m } if (vibrate) { Vibrator vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE); vibrator.vibrate(VIBRATE_DURATION); } }
From source file:org.protocoderrunner.apprunner.api.PDevice.java
@ProtoMethod(description = "makes the phone vibrate", example = "android.vibrate(500);") @ProtoMethodParam(params = { "duration" }) public void vibrate(int duration) { Vibrator v = (Vibrator) getContext().getSystemService(Context.VIBRATOR_SERVICE); v.vibrate(duration); }
From source file:com.iss.android.wearable.datalayer.MainActivity.java
private void displayBatteryWarning(int warned) { // Display a cancelable warning that the HRM battery is running low. AlertDialog.Builder builder = new AlertDialog.Builder(this); String warning = ""; switch (warned) { case 1:/*from w ww . j ava2 s . co m*/ warning = "HRM Battery Level at 15%"; break; case 2: warning = "HRM Battery Level at 10%"; break; case 3: warning = "HRM Battery Level at 5%"; break; } Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); v.vibrate(100); builder.setMessage(warning).setTitle(R.string.battery_warning_title).setCancelable(true) .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.cancel(); dialog.dismiss(); } }); AlertDialog dialog = builder.create(); dialog.setCancelable(true); dialog.show(); }
From source file:org.disrupted.rumble.network.NetworkCoordinator.java
public void onEvent(ChatMessageReceived event) { // check the toggle variable before sending notification or vibration if (!isChatTabFocused) { Intent chatIntent = new Intent(this, HomeActivity.class); // on pressing this notification should open chat tab instead of status tab chatIntent.putExtra("chatTab", 1); chatIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent pIntent = PendingIntent.getActivity(this, 0, chatIntent, 0); chatCounter++;/*from w ww.j a v a2 s. c o m*/ String notificationContent; if (chatCounter == 1) { notificationContent = "" + chatCounter + " chat received"; } else { notificationContent = "" + chatCounter + " chats received"; } mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); NotificationCompat.Builder notification = showNotification("Rumble", notificationContent, notificationContent, R.drawable.small_icon, pIntent, false); mNotificationManager.notify(CHAT_NOTIFICATION_ID, notification.setAutoCancel(true).build()); Vibrator vibrator = (Vibrator) getApplicationContext().getSystemService(Context.VIBRATOR_SERVICE); vibrator.vibrate(300); } }
From source file:com.ght.cerberus.StatusFragment.java
private void raiseAlarm() { Vibrator v = (Vibrator) getContext().getSystemService(Context.VIBRATOR_SERVICE); // Vibrate for 500 milliseconds v.vibrate(500); }
From source file:org.artoolkit.ar.samples.ARSimple.ARSimple.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main);// www. j av a 2 s. c om m0 = MediaPlayer.create(this, R.raw.monson); m1 = MediaPlayer.create(this, R.raw.marker1); m2 = MediaPlayer.create(this, R.raw.marker2); m3 = MediaPlayer.create(this, R.raw.grelot); simpleRenderer.bindPlayers(m1, m2); mainLayout = (FrameLayout) this.findViewById(R.id.mainLayout); seeText = (TextView) this.findViewById(R.id.see); searchText = (TextView) this.findViewById(R.id.search); playText = (TextView) this.findViewById(R.id.play); //searchText.setVisibility(View.GONE); seeText.setVisibility(View.GONE); playText.setVisibility(View.GONE); if (!checkCameraPermission()) { //if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.CAMERA)) { //ASK EVERY TIME - it's essential! ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.CAMERA }, MY_PERMISSIONS_REQUEST_CAMERA); } app = this; // When the screen is tapped, inform the renderer and vibrate the phone mainLayout.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { searchText.setVisibility(View.GONE); simpleRenderer.click(m1); Vector<Integer> newSound = DicoSon.getProfile(++profile); for (int i = 0; i < newSound.size(); ++i) { m0.stop(); m1.stop(); m2.stop(); m3.stop(); m0.reset(); m1.reset(); m2.reset(); m3.reset(); m1 = MediaPlayer.create(app, newSound.get(0)); m2 = MediaPlayer.create(app, newSound.get(1)); m0 = MediaPlayer.create(app, newSound.get(2)); m3 = MediaPlayer.create(app, newSound.get(3)); } Toast.makeText(app, "Profil :" + Integer.toString((profile % 4) + 1), Toast.LENGTH_SHORT).show(); Log.i("Profil :", Integer.toString((profile % 4) + 1)); /* setVolumeControlStream(AudioManager.STREAM_MUSIC); SoundPool soundPool = new SoundPool(20, AudioManager.STREAM_MUSIC, 0); AssetManager assetManager = getAssets(); AssetFileDescriptor descriptor=null; try { descriptor = assetManager.openFd("raw/monson.ogg"); explosionId = soundPool.load(descriptor, 1); soundPool.setOnLoadCompleteListener(new OnLoadCompleteListener() { public void onLoadComplete(SoundPool soundPool, int sampleId,int status) { loaded = true; soundPool.play(explosionId, 1, 1, 0, 0, 1); } }); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } */ Vibrator vib = (Vibrator) getSystemService(VIBRATOR_SERVICE); vib.vibrate(40); } }); }