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:digital.dispatch.TaxiLimoNewUI.GCM.GCMIntentService.java
@Override protected void onMessage(Context context, Intent intent) { String message = intent.getStringExtra("message"); c = context;// w ww . j ava 2s. c o m Logger.v(TAG, "Received message " + message); if (!message.isEmpty()) { if (checkDisplayMsg(context, message, intent)) { WakeLocker.acquire(context); displayMessage(context, gcmType.message, message, id); sendNotification(context, message); Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); v.vibrate(500); WakeLocker.release(); } } }
From source file:com.peppermint.peppermint.ui.AnswerFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mGlowpad = (GlowPadWrapper) inflater.inflate(R.layout.answer_fragment, container, false); vibrator = (Vibrator) getActivity().getSystemService(Context.VIBRATOR_SERVICE); myAudioManager = (AudioManager) getActivity().getSystemService(Context.AUDIO_SERVICE); Uri ring = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE); r = RingtoneManager.getRingtone(getContext(), ring); r.play();/*from w w w . ja v a 2 s . c om*/ long[] pattern = { 100, 1000, 2000, 1000, 2000, 1000, 2000 }; vibrator.vibrate(pattern, 2); LOGD(TAG, " Creating view for answer fragment"); LOGD(TAG, "Created from activity" + getActivity()); mGlowpad.setAnswerListener(this); mGlowpad.startPing(); callActivity = (CallActivity) getContext(); return mGlowpad; }
From source file:nl.johndekroon.dma.GCMIntentService.java
@Override protected void onMessage(Context context, Intent intent) { prefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext()); prefs.getBoolean("muteAll", false); String data = intent.getStringExtra("message"); JSONObject datajson;/*from w w w. j av a 2s . co m*/ try { datajson = new JSONObject(data); String message = datajson.get("message").toString(); String type = datajson.get("type").toString(); String monitor = datajson.get("monitor").toString(); DatabaseDAO datasource = new DatabaseDAO(this); datasource.open(); //On getting a warning or an OK if (type.equals("WARNING") || type.equals("OK")) { if (prefs.getBoolean("muteAll", false) != true) { Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); long[] pattern = { 0, 500, 200, 200 }; // Only perform this pattern one time (-1 means "do not repeat") v.vibrate(pattern, -1); Uri alert = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); if (alert == null) { // I can't see this ever being null (as always have a default notification) but just incase // alert backup is null, using 2nd backup alert = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM); } Ringtone r = RingtoneManager.getRingtone(getApplicationContext(), alert); r.play(); } datasource.updateScenario(monitor, type); generateNotification(context, message); } //on receiving an error else if (type.equals("ERROR")) { System.out.println("bbbrrrrrrr brrrrrr"); Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); long[] pattern = { 0, 1000, 50, 200, 50, 200, 50, 1200 }; // Only perform this pattern one time (-1 means "do not repeat") v.vibrate(pattern, -1); if (prefs.getBoolean("muteAll", false) != true) { Uri alert = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); if (alert == null) { alert = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM); } Ringtone r = RingtoneManager.getRingtone(getApplicationContext(), alert); r.play(); } datasource.updateScenario(monitor, type); generateNotification(context, message); } //on register, make a new scenario. else if (type.equals("REGISTER")) { datasource.createScenario(monitor); } System.out.println(intent.getStringExtra("message")); Log.i(TAG, "Received message"); //No idea why this part isn't working. It should. // if(type.equals("ERROR")) // { // displayMessage(context, message, "error"); // } // else // { displayMessage(context, message); // } } catch (JSONException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } }
From source file:com.fillerino.wallet.ui.ScanActivity.java
@Override public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); setContentView(com.fillerino.wallet.R.layout.scan_activity); scannerView = (ScannerView) findViewById(com.fillerino.wallet.R.id.scan_activity_mask); }
From source file:ua.com.spasetv.testintuitions.FragExerciseThree.java
@Override public void onAttach(Activity activity) { super.onAttach(activity); this.rndHelper = new RndHelper(ID_EXERCISE_THREE); this.arrayAnswers = rndHelper.getArrayAnswers(); this.vibrator = (Vibrator) getActivity().getSystemService(Context.VIBRATOR_SERVICE); this.contentValues = new ContentValues(); this.dataBaseHelper = new DataBaseHelper(activity); try {/*w ww.j a va 2 s .co m*/ onExerciseFinishListener = (OnExerciseFinishListener) activity; } catch (ClassCastException e) { throw new ClassCastException(activity.toString() + " must implement OnExerciseFinishListener"); } }
From source file:com.xortech.sender.SenderSend.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.sender_send, container, false); // GPS INSTANCE gps = new GPSTracker(context); // BUTTONS FOR MAIN LAYOUT panicButton = (Button) rootView.findViewById(R.id.panicBtn); btnShowLocation = (Button) rootView.findViewById(R.id.sendSABtn); vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE); // LOAD PREFERENCES preferences = PreferenceManager.getDefaultSharedPreferences(context); myEmail = preferences.getString("myEmail", DEFAULT_EMAIL); name = preferences.getString("tagID", DEFAULT_TAGID); preferences.registerOnSharedPreferenceChangeListener(this); // TODO: Check for GMAIL using regular expression // (\W|^)[\w.+\-]{0,25}@(yahoo|hotmail|gmail)\.com(\W|$) /**//from www. ja va2s .co m * LISTENER FOR THE SEND LOCATION BUTTON THAT SENDS THIS HANDSETS COORDINATES TO THE * PHONE NUMBERS LOCATED IN THE PANIC NUMBERS DATABASE * * */ btnShowLocation.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { // GET THE COORDINATE STRING FOR GOOGLE MAPS location = GetCoordinates(); try { if (location != null) { SendToMyPanicNumbers(location); Toast.makeText(context, "Your Location is - \nLat: " + latitude + "\nLong: " + longitude, Toast.LENGTH_LONG).show(); } else { Toast.makeText(context, "Coordinates Unavailable", Toast.LENGTH_LONG).show(); } } catch (Exception e) { Log.e("Error sending SMS: ", "" + e); } } }); /** * LISTENER FOR PANIC BUTTON. SENDS A MESSAGE EVER MINUE FOR TEN MINUTES IF THE PANIC * FEATURE IS ACTIVATED * * */ panicButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { // CHANGE PANIC BUTTON TEXT BASED ON STATUS if (panic == false) { panic = true; panicButton.setText(STOP_TEXT); } else if (panic == true) { panic = false; panicButton.setText(PANIC_TEXT); } if (panic == true) { // CRAFT A MESSAGE panicLocation = GetCoordinates(); panicMsg = "Panic!\n" + panicLocation; // START THE TIMER mytimer = new Timer(true); final TimerTask mytask = new TimerTask() { public void run() { SendToMyPanicNumbers(panicMsg); } }; // START THE TIME AFTER ONE SECOND AND SEND NEW SMS EVERY 60 SECONDS mytimer.schedule(mytask, ONE_SECOND, ONE_MINUTE); // VIBRATE FOR 3000 MILLISECONDS OR 3 SECONDS vibrator.vibrate(THREE_SECONDS); // DISPLAY ACTIVATION Toast.makeText(context, "Panic Activated!", Toast.LENGTH_LONG).show(); } // CANCEL PANIC else if (panic == false) { // CANCEL TIMER mytimer.cancel(); // DISPLAY CANCEL, SET PANIC FALSE, AND REVERT TEXT Toast.makeText(context, "Panic Cancelled", Toast.LENGTH_LONG).show(); panic = false; panicButton.setText(PANIC_TEXT); } } }); return rootView; }
From source file:net.czlee.debatekeeper.AlertManager.java
/** * Constructor.// w ww. j av a2 s . co m * @param debatingTimerService The instance of {@link DebatingTimerService} to which this * AlertManager relates */ public AlertManager(Service debatingTimerService) { mService = debatingTimerService; // System services mNotificationManager = (NotificationManager) debatingTimerService .getSystemService(Context.NOTIFICATION_SERVICE); mVibrator = (Vibrator) debatingTimerService.getSystemService(Context.VIBRATOR_SERVICE); mPowerManager = (PowerManager) mService.getSystemService(Context.POWER_SERVICE); // Create a PendingIntent for the notification we raise while the timer is running. Intent intent = new Intent(debatingTimerService, DebatingActivity.class); // This flag prevents the activity from having multiple instances on the back stack, // so that when the user presses the notification while already in Debatekeeper, pressing // back won't make the user go through several instances of Debatekeeper on the back stack. intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); mIntentForOngoingNotification = PendingIntent.getActivity(debatingTimerService, 0, intent, 0); // Set up defaults Resources res = mService.getResources(); mSilentMode = res.getBoolean(R.bool.prefDefault_silentMode); mVibrateMode = res.getBoolean(R.bool.prefDefault_vibrateMode); createWakeLock(); }
From source file:com.coinomi.wallet.ui.ScanActivity.java
@Override public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); setContentView(R.layout.scan_activity); scannerView = (ScannerView) findViewById(R.id.scan_activity_mask); }
From source file:com.google.android.apps.forscience.whistlepunk.metadata.TriggerHelper.java
public void doVibrateAlert(Context context) { // Use a throttler to keep this from interrupting itself too much. if (System.currentTimeMillis() - mLastVibrationMs < THROTTLE_LIMIT_MS) { return;/* w w w. j av a 2 s. c om*/ } mLastVibrationMs = System.currentTimeMillis(); if (mVibrator == null) { mVibrator = ((Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE)); } mVibrator.vibrate(TRIGGER_VIBRATION_DURATION_MS); }
From source file:edu.rit.csh.androidwebnews.UpdaterService.java
/** * The IntentService calls this method from the default worker thread with * the intent that started the service. When this method returns, IntentService * stops the service, as appropriate./* w w w. j ava 2s . c om*/ */ @Override protected void onHandleIntent(Intent intent) { Vibrator mVibrator; Uri notification; Ringtone r; SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this); HttpsConnector hc = new HttpsConnector(this); int[] statuses; try { statuses = hc.getUnreadCount(); // throws all the errors // if there are WebNews new posts and that number is different than last time the update ran if (statuses[0] != 0 && statuses[0] != sharedPref.getInt("number_of_unread", 0)) { SharedPreferences.Editor editor = sharedPref.edit(); editor.putInt("number_of_unread", statuses[0]); editor.commit(); NotificationCompat.Builder builder = new NotificationCompat.Builder(this); builder.setContentTitle(getString(R.string.app_name)); builder.setSmallIcon(R.drawable.notification_icon); builder.setAutoCancel(true); if (statuses[2] != 0) { if (statuses[2] == 1) { builder.setContentText(statuses[2] + " reply to your post"); } else { builder.setContentText(statuses[2] + " reply to your posts"); } } else if (statuses[1] != 0) { if (statuses[1] == 1) { builder.setContentText(statuses[1] + " unread post in your thread"); } else { builder.setContentText(statuses[1] + " unread posts in your thread"); } } else { if (statuses[0] == 1) { builder.setContentText(statuses[0] + " unread post"); } else { builder.setContentText(statuses[0] + " unread posts"); } } if (sharedPref.getBoolean("vibrate_service", true)) { mVibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); mVibrator.vibrate(500); } if (sharedPref.getBoolean("ring_service", false)) { notification = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); r = RingtoneManager.getRingtone(getApplicationContext(), notification); r.play(); } // Creates an explicit intent for an Activity in your app /* The stack builder object will contain an artificial back stack for the started Activity. This ensures that navigating backward from the Activity leads out of your application to the Home screen. */ // notification is selected Intent notificationIntent = new Intent(this, RecentActivity.class); PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT); builder.setContentIntent(contentIntent); // Add as notification NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); manager.notify(0, builder.build()); } else if (statuses[0] == 0) { // if all post have been read /* if a user reads all the posts, the notification is removed */ NotificationManager mNotificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); mNotificationManager.cancel(0); } } catch (InvalidKeyException e) { NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this); mBuilder.setContentTitle(getString(R.string.app_name)); mBuilder.setSmallIcon(R.drawable.notification_icon); mBuilder.setContentText("Invalid API Key"); mBuilder.setAutoCancel(true); Intent resultIntent = new Intent(this, SettingsActivity.class); TaskStackBuilder stackBuilder; try { stackBuilder = TaskStackBuilder.create(this); } catch (Exception e1) { return; } // Adds the back stack for the Intent (but not the Intent itself) stackBuilder.addParentStack(SettingsActivity.class); // Adds the Intent that starts the Activity to the top of the stack stackBuilder.addNextIntent(resultIntent); PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); mBuilder.setContentIntent(resultPendingIntent); NotificationManager mNotificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); // mId allows you to update the notification later on. mNotificationManager.notify(0, mBuilder.build()); } catch (NoInternetException e) { // do nothing if there is no internet for the background service } catch (InterruptedException e) { // normally never hit } catch (ExecutionException e) { // normally never hit } }