List of usage examples for android.os Vibrator vibrate
@RequiresPermission(android.Manifest.permission.VIBRATE) public void vibrate(VibrationEffect vibe)
From source file:com.hackathon.BeatTheQueue.reusable.gcm.GcmIntentService.java
private void sendNotification(String msg) { mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE); PendingIntent contentIntent = null;/* ww w . j ava2 s .c o m*/ if (BTQSharedPreferences.getString(StringConstants.PREF_APP_TYPE, "") .contains(StringConstants.APP_TYPE_NON_AMBULANCE)) { Intent intent = new Intent(this, NotificationActivity.class); intent.putExtra("msg", msg); contentIntent = PendingIntent.getActivity(this, 0, intent, 0); } NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.mipmap.lets_save_a_life) .setContentTitle("DropByDrop").setStyle(new NotificationCompat.BigTextStyle().bigText("DropByDrop")) .setContentText(msg); Bitmap largeIcon = BitmapFactory.decodeResource(getResources(), R.mipmap.lets_save_a_life); mBuilder.setLargeIcon(largeIcon); mBuilder.setContentIntent(contentIntent); mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build()); Vibrator vibrator = (Vibrator) getApplicationContext().getSystemService(Context.VIBRATOR_SERVICE); vibrator.vibrate(1000); Log.e("GCMBroadcastReceiver", ">>>>>>>>>>>>>>Msg Received"); }
From source file:com.gestao.udec.gestao_mobile.ARSimple.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main);/*from w w w. ja v a2s .c om*/ simpleRenderer = new SimpleRenderer(getApplicationContext()); mainLayout = (FrameLayout) this.findViewById(R.id.mainLayout); 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); } // When the screen is tapped, inform the renderer and vibrate the phone mainLayout.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { simpleRenderer.click(); Vibrator vib = (Vibrator) getSystemService(VIBRATOR_SERVICE); vib.vibrate(40); } }); }
From source file:com.vibrationapps.Vibration.java
/** * Executes the request and returns PluginResult. * * @param action The action to execute. * @param args JSONArray of arguments for the plugin. * @param callbackContext The callback context used when calling back into JavaScript. * @return True when the action was valid, false otherwise. *//*from w ww . j av a 2 s. c o m*/ public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { Vibrator vibra = (Vibrator) cordova.getActivity().getSystemService(Context.VIBRATOR_SERVICE); if (action.equals("vibrate")) { vibra.vibrate(args.getLong(0)); } else if (action.equals("vibrateArr")) { JSONArray jsonArray = (JSONArray) args.getJSONArray(0); long[] list = new long[jsonArray.length()]; if (jsonArray != null) { int len = jsonArray.length(); for (int i = 0; i < len; i++) { list[i] = jsonArray.getLong(i); } } vibra.vibrate(list, args.getInt(1)); } else if (action.equals("cancel")) { vibra.cancel(); } else if (action.equals("hasVibrator")) { } else { return false; } // Only alert and confirm are async. callbackContext.success(); return true; }
From source file:org.frb.sf.frbn.GCMIntentService.java
@Override protected void onMessage(Context context, Intent intent) { Log.i(TAG, "Received message"); //String message = getString(R.string.gcm_message); //String message = getString(R.string.gcm_message) + ": " + intent.getExtras().getString("message"); String message = intent.getExtras().getString("message"); String title = intent.getExtras().getString("title"); String district = intent.getExtras().getString("district"); String category = intent.getExtras().getString("category"); String timestamp = intent.getExtras().getString("timestamp"); //Date dt = new Date(Long.parseLong(timestamp, 10)); MessageManager manager = new MessageManager(context); Message messageObj = new Message(message, title, category, district, Long.parseLong(timestamp)); manager.addMessageItem(messageObj);/*ww w .j av a 2 s.c o m*/ displayMessage(context, message); // notifies user generateNotification(context, messageObj); Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); v.vibrate(300); }
From source file:com.cybrosys.basic.EventListener.java
public void vibrate() { SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(PalmCalcActivity.ctx); Boolean isVibe = sharedPrefs.getBoolean("prefVibe", false); Vibrator vibe = (Vibrator) PalmCalcActivity.ctx.getSystemService(Context.VIBRATOR_SERVICE); if (isVibe) { vibe.vibrate(100); }// ww w .j av a2 s.c o m }
From source file:com.kawakawaplanning.rssreader.Main.MainActivity.java
public void browser(View v) { Vibrator vib = (Vibrator) getSystemService(VIBRATOR_SERVICE); vib.vibrate(50); Intent intent = new Intent(); intent.setAction(Intent.ACTION_WEB_SEARCH); intent.putExtra(SearchManager.QUERY, "RSS ????"); startActivity(intent);/* w ww .jav a 2s . c o m*/ }
From source file:com.developer.shade.sensors.SensorService.java
private void onSystemVibrate(int milli) { Log.d("Running onSystem", "Running Internal Device Vibrator"); Vibrator oVibrate = (Vibrator) getSystemService(VIBRATOR_SERVICE); if (oVibrate.hasVibrator()) { oVibrate.vibrate(milli); }/*from w ww . jav a2s. c o m*/ }
From source file:net.noio.Reminder.NotificationService.java
private void Notify(Intent intent) { // Notification on drop down bar PendingIntent pimain = PendingIntent.getActivity(getApplicationContext(), intent.getIntExtra("id", 0), intent, 0);//from ww w . j av a2 s . com NotificationCompat.Builder notif = new NotificationCompat.Builder(getApplicationContext()); notif.setSmallIcon(R.drawable.ic_launcher); notif.setContentTitle(intent.getStringExtra("reminder")); notif.setContentText(intent.getStringExtra("string")); notif.setContentIntent(pimain); notif.setAutoCancel(true); NotificationManager notman = (NotificationManager) getApplicationContext() .getSystemService(Context.NOTIFICATION_SERVICE); Vibrator v = (Vibrator) getApplicationContext().getSystemService(Context.VIBRATOR_SERVICE); v.vibrate(this.VIBRATE_TIME); notman.notify(intent.getIntExtra("id", 0), notif.build()); }
From source file:eu.iescities.pilot.rovereto.roveretoexplorer.fragments.event.info.edit.AddressSelectActivity.java
@Override public void onMapLongClick(LatLng point) { Vibrator vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE); vibrator.vibrate(100); // GeoPoint p = new GeoPoint((int) (point.latitude * 1e6), (int) // (point.longitude * 1e6)); GeoPoint p = new GeoPoint((int) (point.latitude * 1e6), (int) (point.longitude * 1e6)); // List<OSMAddress> addresses = new // SCGeocoder(getApplicationContext(),url).findAddressesAsync(p); // addresses = new // OSMGeocoder(getApplicationContext(),url).getFromLocation(point.latitude // , point.longitude, null); new SCAsyncTask<Void, Void, List<OSMAddress>>(this, new GetAddressProcessor((Activity) this, p)).execute(); }
From source file:nortti.ru.gomoscow.GeofenceTransitionsIntentService.java
/** * Handles incoming intents.//from w ww. j av a2s.com * @param intent sent by Location Services. This Intent is provided to Location * Services (inside a PendingIntent) when addGeofences() is called. */ @Override protected void onHandleIntent(Intent intent) { GeofencingEvent geofencingEvent = GeofencingEvent.fromIntent(intent); if (geofencingEvent.hasError()) { String errorMessage = GeofenceErrorMessages.getErrorString(this, geofencingEvent.getErrorCode()); Log.e(TAG, errorMessage); return; } // Get the transition type. int geofenceTransition = geofencingEvent.getGeofenceTransition(); // Test that the reported transition was of interest. if (geofenceTransition == Geofence.GEOFENCE_TRANSITION_ENTER || geofenceTransition == Geofence.GEOFENCE_TRANSITION_EXIT) { // Get the geofences that were triggered. A single event can trigger multiple geofences. List<Geofence> triggeringGeofences = geofencingEvent.getTriggeringGeofences(); // Get the transition details as a String. String geofenceTransitionDetails = getGeofenceTransitionDetails(this, geofenceTransition, triggeringGeofences); // Send notification and log the transition details. sendNotification(geofenceTransitionDetails); Vibrator v = (Vibrator) this.getSystemService(Context.VIBRATOR_SERVICE); v.vibrate(500); Log.i(TAG, geofenceTransitionDetails); } else { // Log the error. Log.e(TAG, getString(R.string.geofence_transition_invalid_type, geofenceTransition)); } }