List of usage examples for android.content Context VIBRATOR_SERVICE
String VIBRATOR_SERVICE
To view the source code for android.content Context VIBRATOR_SERVICE.
Click Source Link
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);/*from www . jav a2s . co m*/ 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(); } }); AlertDialog dialog = builder.create(); dialog.show(); }
From source file:com.anysoftkeyboard.AnySoftKeyboard.java
@Override public void onCreate() { super.onCreate(); mOrientation = getResources().getConfiguration().orientation; if ((!BuildConfig.DEBUG) && DeveloperUtils.hasTracingRequested(getApplicationContext())) { try {/*from w w w.j a va 2 s . c o m*/ DeveloperUtils.startTracing(); Toast.makeText(getApplicationContext(), R.string.debug_tracing_starting, Toast.LENGTH_SHORT).show(); } catch (Exception e) { //see issue https://github.com/AnySoftKeyboard/AnySoftKeyboard/issues/105 //I might get a "Permission denied" error. e.printStackTrace(); Toast.makeText(getApplicationContext(), R.string.debug_tracing_starting_failed, Toast.LENGTH_LONG) .show(); } } Logger.i(TAG, "****** AnySoftKeyboard v%s (%d) service started.", BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE); if (!BuildConfig.DEBUG && BuildConfig.VERSION_NAME.endsWith("-SNAPSHOT")) throw new RuntimeException("You can not run a 'RELEASE' build with a SNAPSHOT postfix!"); if (mAskPrefs.getAnimationsLevel() != AskPrefs.AnimationsLevel.None) { final int fancyAnimation = getResources().getIdentifier("Animation_InputMethodFancy", "style", "android"); if (fancyAnimation != 0) { Logger.i(TAG, "Found Animation_InputMethodFancy as %d, so I'll use this", fancyAnimation); getWindow().getWindow().setWindowAnimations(fancyAnimation); } else { Logger.w(TAG, "Could not find Animation_InputMethodFancy, using default animation"); getWindow().getWindow().setWindowAnimations(android.R.style.Animation_InputMethod); } } mInputMethodManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE); mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); updateRingerMode(); // register to receive ringer mode changes for silent mode registerReceiver(mSoundPreferencesChangedReceiver, mSoundPreferencesChangedReceiver.createFilterToRegisterOn()); // register to receive packages changes registerReceiver(mPackagesChangedReceiver, mPackagesChangedReceiver.createFilterToRegisterOn()); mVibrator = ((Vibrator) getSystemService(Context.VIBRATOR_SERVICE)); onLoadSettingsRequired(PreferenceManager.getDefaultSharedPreferences(this)); mAskPrefs.addChangedListener(this); mVoiceRecognitionTrigger = new VoiceRecognitionTrigger(this); }
From source file:com.trailbehind.android.iburn.map.MapActivity.java
/** * Sets the app params.//from ww w . jav a 2s .co m */ private void setActivityParams() { setDefaultKeyMode(DEFAULT_KEYS_SEARCH_LOCAL); getWindow().setBackgroundDrawable(null); mVibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); mActivityHandler.sendMessage(mActivityHandler.obtainMessage(ActivityHandler.MESSAGE_INIT_FILE_SYSTEM_DIR)); mMapDownloadThreads = new MapDownloadThread[DOWNLOAD_THREAD_COUNT]; }
From source file:app.abhijit.iter.MainActivity.java
private void vibrate() { Vibrator vibrator = (Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE); vibrator.vibrate(500); }
From source file:it.jaschke.alexandria.barcodeapi.BarcodeCaptureActivity.java
@Override public void onBarcodeFound(Barcode barcode) { if (barcode != null) { Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); v.vibrate(50);//from w w w.j a va 2 s. c o m Intent data = new Intent(); data.putExtra(BarcodeObject, barcode); setResult(CommonStatusCodes.SUCCESS, data); finish(); } else { Log.d(TAG, "barcode data is null"); } }
From source file:shetye.prathamesh.notifyme.Utilities.java
public void generateNotification(Context context, int ID, String title, String message, boolean isOngoing) { NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); Intent notificationIntent = new Intent(context, NotifyMe.class); notificationIntent.setData(Uri.parse(Integer.toString(ID))); notificationIntent.putExtra(Utilities.NOTIF_EXTRA_ID_KEY, ID); notificationIntent.putExtra(Utilities.NOTIF_EXTRA_KEY, message); notificationIntent.putExtra(Utilities.NOTIF_EXTRA_TITLE_KEY, title); Intent laterIntent = new Intent(context, NotificationDetail.class); laterIntent.setData(Uri.parse(Integer.toString(ID))); laterIntent.putExtra(Utilities.NOTIF_EXTRA_ID_KEY, ID); laterIntent.putExtra(Utilities.NOTIF_EXTRA_DONE_LATER_KEY, true); Intent doneIntent = new Intent(context, RecieveAndNotify.class); doneIntent.setData(Uri.parse(Integer.toString(ID))); doneIntent.setAction(NOTIF_SERVICE_DONE_ACTION); doneIntent.putExtra(Utilities.NOTIF_EXTRA_ID_KEY, ID); PendingIntent resultPendingIntent = PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT); PendingIntent remindLaterIntent = PendingIntent.getActivity(context, 0, laterIntent, PendingIntent.FLAG_UPDATE_CURRENT); PendingIntent completedIntent = PendingIntent.getBroadcast(context, 0, doneIntent, PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle(); String newTitle;// w w w. j a v a 2 s.c o m if (title == null || title.isEmpty()) newTitle = context.getResources().getString(R.string.app_name); else newTitle = title; inboxStyle.setBigContentTitle(newTitle); inboxStyle.addLine(message); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context) .setSmallIcon(R.drawable.ic_notif).setContentTitle(newTitle).setContentText(message) .setPriority(NotificationCompat.PRIORITY_MAX).setContentIntent(resultPendingIntent) .addAction(R.drawable.ic_restore, "Later", remindLaterIntent) .addAction(R.drawable.ic_done, "Done", completedIntent).setStyle(inboxStyle); Log.d(LOG_TAG, "Notifying for ID : " + ID); notificationManager.notify(ID, mBuilder.build()); try { Uri notification = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); Ringtone r = RingtoneManager.getRingtone(context, notification); Vibrator v = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE); // Vibrate for 300 milliseconds v.vibrate(200); r.play(); } catch (Exception e) { e.printStackTrace(); } }
From source file:org.ttrssreader.utils.Utils.java
/** * Alert the user by a short vibration or a flash of the whole screen. *///w ww . j a v a2 s. com public static void alert(Activity activity, boolean error) { Vibrator vib = ((Vibrator) activity.getSystemService(Context.VIBRATOR_SERVICE)); if (vib.hasVibrator()) { vib.vibrate(Utils.SHORT_VIBRATE); } else if (error) { // Only flash when user tried to move forward, flashing when reaching the last article looks just wrong. Animation flash = AnimationUtils.loadAnimation(activity, R.anim.flash); View main = activity.findViewById(R.id.frame_all); main.startAnimation(flash); } }
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 w w . j a v a 2 s. c o 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.xbmc.kore.utils.UIUtils.java
public static void handleVibration(Context context) { if (context == null) return;// w w w. j av a 2 s.co m Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE); if (!vibrator.hasVibrator()) return; //Check if we should vibrate boolean vibrateOnPress = PreferenceManager.getDefaultSharedPreferences(context) .getBoolean(Settings.KEY_PREF_VIBRATE_REMOTE_BUTTONS, Settings.DEFAULT_PREF_VIBRATE_REMOTE_BUTTONS); if (vibrateOnPress) { vibrator.vibrate(UIUtils.buttonVibrationDuration); } }
From source file:fi.iki.murgo.irssinotifier.IrssiNotifierActivity.java
public void newMessage(IrcMessage msg) { if ((!preferences.isSpamFilterEnabled() || new Date().getTime() > IrcNotificationManager.getInstance().getLastSoundDate() + 60000L)) { Uri sound = preferences.getNotificationSound(); if (sound != null) { MediaPlayer mp = MediaPlayer.create(this, sound); if (mp != null) { mp.start();//from w ww . j a v a2 s . c om } } if (preferences.isVibrationEnabled()) { Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); if (v != null) { v.vibrate(500); } } IrcNotificationManager.getInstance().setLastSoundDate(new Date().getTime()); } if (preferences.isFeedViewDefault()) { channelToView = FEED; } else { channelToView = msg.getLogicalChannel(); } startMainApp(false); }