@Override protected void onHandleIntent(@Nullable Intent intent) { isRunning = true; showForegroundNotification(); name = intent.getStringExtra(EXTRA_ACTIVITY_TYPE); storage = new StorageUtil(name); startAccelerometer(); try { Thread.sleep(Config.LENGTH_RECORDING_IN_MINUTES * 60 * 1000); } catch (InterruptedException e) { } stopAccelerometer(); storage.close(); RecorderFinishedEvent event = new RecorderFinishedEvent(); event.activityType = name; EventBus.getDefault().post(event); isRunning = false; hideForegroundNotification(); ToneGenerator beep = new ToneGenerator(AudioManager.STREAM_MUSIC, 500); beep.startTone(ToneGenerator.TONE_CDMA_HIGH_L, 1000); }
/** * 'Warns' the user, where multiple warnings will cause the HUD to turn red in appearance and flash. */ public void warn() { if (System.currentTimeMillis() - lastWarnTime > WARN_RATE) { lastWarnTime = System.currentTimeMillis(); warnAmount = Math.min(1.0f, warnAmount + WARN_AMOUNT_INCR); lastWarn = System.currentTimeMillis(); if (beepsEnabled && warnAmount > DANGER_WARN_AMOUNT && lastWarn - lastToneTime > TONE_DELAY && RobotController.getSpeed() > 0.01) { lastToneTime = lastWarn; toneGenerator.startTone(ToneGenerator.TONE_PROP_BEEP, (int) TONE_DELAY / 2); } } }
/** * Plays debug sound * @param name */ protected void startTone(String name) { int tone = 0; int duration = 1000; if (name.equals("beep")) { tone = ToneGenerator.TONE_PROP_BEEP; } else if (name.equals("beep_beep_beep")) { tone = ToneGenerator.TONE_CDMA_CONFIRM; } else if (name.equals("long_beep")) { tone = ToneGenerator.TONE_CDMA_ABBR_ALERT; } else if (name.equals("doodly_doo")) { tone = ToneGenerator.TONE_CDMA_ALERT_NETWORK_LITE; } else if (name.equals("chirp_chirp_chirp")) { tone = ToneGenerator.TONE_CDMA_ALERT_CALL_GUARD; } else if (name.equals("dialtone")) { tone = ToneGenerator.TONE_SUP_RINGTONE; } toneGenerator.startTone(tone, duration); }
@Override public void onError(int error) { m_isListening = false; synchronized (MyASR.this) { switch (error) { case SpeechRecognizer.ERROR_NO_MATCH: case SpeechRecognizer.ERROR_RECOGNIZER_BUSY: case SpeechRecognizer.ERROR_SPEECH_TIMEOUT: new ToneGenerator(AudioManager.STREAM_MUSIC, ToneGenerator.MAX_VOLUME) .startTone(ToneGenerator.TONE_PROP_BEEP2); break; default: break; } } }
@Override protected void onPostExecute(Void result) { super.onPostExecute(result); try { final ToneGenerator tg = new ToneGenerator(AudioManager.STREAM_NOTIFICATION, 100); tg.startTone(ToneGenerator.TONE_DTMF_0, 300); Thread.sleep(300); tg.startTone(ToneGenerator.TONE_PROP_BEEP2); } catch (InterruptedException e) { e.printStackTrace(); } AAboutMe.instance.setData(); task_save = null; AMain.instance.check_personal_id_status(); AAboutMeEdit.this.finish(); }
@Override protected void onPostExecute(String result) { super.onPostExecute(result); Log.d("CheckPersonalId", "Pid = "+result); try { final ToneGenerator tg = new ToneGenerator(AudioManager.STREAM_NOTIFICATION, 100); tg.startTone(ToneGenerator.TONE_DTMF_0, 300); Thread.sleep(300); tg.startTone(ToneGenerator.TONE_PROP_BEEP2); } catch (InterruptedException e) { e.printStackTrace(); } show_confirm_info(result); task = null; }
public void playTone(int side, float intense) throws InterruptedException { int streamType = AudioManager.STREAM_MUSIC; ToneGenerator toneGenerator = new ToneGenerator(streamType, (int) ((1-intense)*ToneGenerator.MAX_VOLUME)); int durationMs = 50; int waitTime = 50; int toneType; // left if (side == 0) toneType = ToneGenerator.TONE_DTMF_1; // middle else if (side == 1 || side == 2) toneType = ToneGenerator.TONE_DTMF_6; // right else toneType = ToneGenerator.TONE_DTMF_D; toneGenerator.startTone(toneType, durationMs); //toneGenerator.wait(durationMs + waitTime); }
public void run() { long timeStart = Calendar.getInstance().getTimeInMillis(); Log.d(LOG_TAG, "FindSound Start: "+timeStart); ToneGenerator toneG = new ToneGenerator(AudioManager.STREAM_ALARM, ToneGenerator.MAX_VOLUME); while(isFinding) { try { long timeDiff = Calendar.getInstance().getTimeInMillis() - timeStart; Log.d(LOG_TAG, "Sound time: " + timeDiff/1000); toneG.startTone(ToneGenerator.TONE_CDMA_ALERT_CALL_GUARD, 200); // 200 ms tone Thread.sleep(600L); } catch(InterruptedException ie) { Thread.currentThread().interrupt(); return; } } }
protected void startTone(String name) { int tone = 0; int duration = 1000; if (name.equals("beep")) { tone = ToneGenerator.TONE_PROP_BEEP; } else if (name.equals("beep_beep_beep")) { tone = ToneGenerator.TONE_CDMA_CONFIRM; } else if (name.equals("long_beep")) { tone = ToneGenerator.TONE_CDMA_ABBR_ALERT; } else if (name.equals("doodly_doo")) { tone = ToneGenerator.TONE_CDMA_ALERT_NETWORK_LITE; } else if (name.equals("chirp_chirp_chirp")) { tone = ToneGenerator.TONE_CDMA_ALERT_CALL_GUARD; } else if (name.equals("dialtone")) { tone = ToneGenerator.TONE_SUP_RINGTONE; } toneGenerator.startTone(tone, duration); }
private void startTimer(long time) { if (!mIsOver) { mTimer.clearAnimation(); toneGenerator.startTone(ToneGenerator.TONE_CDMA_SIGNAL_OFF); mTimer.setTextColor(Color.WHITE); mVibrator.vibrate(mStartVibrationPattern, -1); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); // keep screen awake when timer is running mCountDownTimer = new CountDownTimer(time, 10) { public void onTick(long millisUntilFinished) { updateTimer(millisUntilFinished); mTimeRemaining = millisUntilFinished; } public void onFinish() { endSection(); getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); // turn screen-awake off when timer is expired } }.start(); mTimerRunning = true; } }
private void calculateStatus(){ currentStatus = (int)(((batteryVoltage - minVoltage) / (maxVoltage - minVoltage))*100); if (currentStatus!=batteryStatus){ batteryStatus = currentStatus; if (System.currentTimeMillis() - timer > CHECKING_TIME){ sendData(batteryStatus); // Send to message queue timer = System.currentTimeMillis(); if(batteryStatus<1){ // Battery protection. When battery gets dangerously low. Stop the copter. MainController.getInstance().emergencyStop("Drained Battery"); ToneGenerator toneG = new ToneGenerator(AudioManager.STREAM_ALARM, 100); toneG.startTone(ToneGenerator.TONE_CDMA_ALERT_CALL_GUARD, 200); } } } }
@Override public boolean onKeyDown(int keyCode,KeyEvent event){ super.onKeyDown(keyCode, event); if(keyCode== KeyEvent.KEYCODE_DPAD_CENTER){ final ToneGenerator tg = new ToneGenerator(AudioManager.STREAM_NOTIFICATION, 100); tg.startTone(ToneGenerator.TONE_PROP_BEEP); mIsFinderActive= !mIsFinderActive; if(mIsFinderActive){ mTextView.setText("Scanning..."); mCloudRecognition.startFinding(); }else{ mTextView.setText("Tap to scan"); mCloudRecognition.stopFinding(); } return true; } return false; }
@Override public void run() { String myString = "1010101"; final ToneGenerator tg = new ToneGenerator(AudioManager.STREAM_NOTIFICATION, 5000); long blinkDelay = 50; //Delay in ms for (int i = 0; i < myString.length(); i++) { if (myString.charAt(i) == '0') { turnOnSOS(); tg.startTone(ToneGenerator.TONE_DTMF_6, 50); } else { turnOffSOS(); } try { Thread.sleep(blinkDelay); } catch (InterruptedException e) { e.printStackTrace(); } } while (!stopRunning) { longSOS(); } }
public void longSOS(){ final ToneGenerator tg = new ToneGenerator(AudioManager.STREAM_NOTIFICATION, 5000); String myString = "010101"; long blinkDelay = 250; //Delay in ms for (int i = 0; i < myString.length(); i++) { if (myString.charAt(i) == '0') { turnOnSOS(); tg.startTone(ToneGenerator.TONE_DTMF_6, 250); //200 is duration in ms } else { turnOffSOS(); } try { Thread.sleep(blinkDelay); } catch (InterruptedException e) { e.printStackTrace(); } } while (!stopRunning) { shortSOS(); } }
public void shortSOS(){ final ToneGenerator tg = new ToneGenerator(AudioManager.STREAM_NOTIFICATION, 5000); String myString = "010101111111"; long blinkDelay = 50; //Delay in ms for (int i = 0; i < myString.length(); i++) { if (myString.charAt(i) == '0') { turnOnSOS(); tg.startTone(ToneGenerator.TONE_DTMF_6, 50); //200 is duration in ms } else { turnOffSOS(); } try { Thread.sleep(blinkDelay); } catch (InterruptedException e) { e.printStackTrace(); } } while (!stopRunning) { run(); } }
@Override public void taskFailed() { Toast.makeText(getApplicationContext(), "Không gọi được", Toast.LENGTH_SHORT).show(); ToneGenerator toneG = new ToneGenerator(AudioManager.STREAM_ALARM, 100); toneG.startTone(ToneGenerator.TONE_CDMA_ALERT_CALL_GUARD, 200); }
@Override protected void onResume() { super.onResume(); ttv = new TextToVoice(this); tonegen = new ToneGenerator(AudioManager.STREAM_MUSIC, 99); setVolumeControlStream(AudioManager.STREAM_MUSIC); if (mSensor!=null) { mSensorManager.registerListener(this, mSensor, SensorManager.SENSOR_DELAY_NORMAL); } speakTimer = new Timer(); }
private CountdownWarning(Builder builder) { super(builder.secondsInFuture * 1000, 50); vibrator = (Vibrator) TwistyTimer.getAppContext().getSystemService(Context.VIBRATOR_SERVICE); this.vibrateEnabled = builder.vibrateEnabled; this.vibrateDuration = builder.vibrateDuration; this.toneEnabled = builder.toneEnabled; this.toneDuration = builder.toneDuration; this.toneCode = builder.toneCode; this.toneGenerator = new ToneGenerator(AudioManager.STREAM_MUSIC, 100); }
@Override public void run() { ToneGenerator toneGenerator = new ToneGenerator(AudioManager.STREAM_MUSIC, 100); if (toneGenerator.startTone(this.sound)) { try { Thread.sleep(250); } catch (InterruptedException e) { e.printStackTrace(); } toneGenerator.stopTone(); } toneGenerator.release(); }
@Override public String exec(ExecutePack pack) throws Exception { try { ToneGenerator toneG = new ToneGenerator(AudioManager.STREAM_ALARM, 50); toneG.startTone(ToneGenerator.TONE_CDMA_ALERT_CALL_GUARD, 1000); } catch (Exception e) { return e.toString(); } return null; }
private static void playTone() { try { ToneGenerator toneGen1 = new ToneGenerator(AudioManager.STREAM_ALARM, 100); toneGen1.startTone(ToneGenerator.TONE_CDMA_ALERT_CALL_GUARD, 100); } catch (RuntimeException ignored) { } }
public static void playGameOverSound() { if (AstroSmashSettings.sound) { new Thread(new Runnable() { @Override public void run() { toneGenerator.startTone(ToneGenerator.TONE_CDMA_PRESSHOLDKEY_LITE); } }).start(); } }
private void parseReceivedData(byte[] data) { ut61pkt u; try { u = new ut61pkt(data); } catch (NumberFormatException e) { Log.i(TAG,"Error reading value"); return; } Log.i(TAG, Arrays.toString(data)); Log.i(TAG, u.toStrDebug()); String calibStatus = "C"; Float dvalue = Float.valueOf(u.value); changed.add(dvalue); String minmax=String.valueOf(changed.Min)+" "+String.valueOf(changed.Max); if (chDetect) { calibStatus = "A "; if (changed.isChange()) { ToneGenerator toneG = new ToneGenerator(AudioManager.STREAM_ALARM, 100); toneG.startTone(ToneGenerator.TONE_CDMA_ALERT_CALL_GUARD, 200); } } mTitleTextView.setText(String.valueOf(u.value) + " " + u.mtype + u.munit + " " +u.acdc+" "+minmax+" "+calibStatus); if (series1.size() > HISTORY_SIZE) { series1.removeFirst(); } series1.addLast(null, u.value); plot.redraw(); // mDumpTextView.append(u.toStr()+"\n"); // mScrollView.smoothScrollTo(0, mDumpTextView.getBottom()); }
@Override public void run() { ToneGenerator toneGen = new ToneGenerator(AudioManager.STREAM_ALARM, 80); while (mTraceRunning) { int avgStrength = mTraceAntSelector.getSignalStrength(); int sleepTime = 1000; int beepDuration = 100; int toneType = ToneGenerator.TONE_DTMF_0; if (avgStrength > 0) { toneType = ToneGenerator.TONE_DTMF_4 + (avgStrength / 10); //ToneGenerator.TONE_DTMF_9; sleepTime = 160 - avgStrength; beepDuration = 50; } if (mEnableBeep) toneGen.startTone(toneType, beepDuration); try { Thread.sleep(sleepTime); } catch (InterruptedException e) { e.printStackTrace(); } } }
public static void beepDevice(int duration) { try { UtilsRG.info("Device is beeping for"); ToneGenerator toneG = new ToneGenerator(AudioManager.STREAM_ALARM, 100); toneG.startTone(ToneGenerator.TONE_CDMA_ALERT_CALL_GUARD, duration); } catch (Exception e) { UtilsRG.info("device could not make a beep"); } }
@Override public void handleResult(Result rawResult) { if (mRing) { try { ToneGenerator beep = new ToneGenerator(AudioManager.STREAM_NOTIFICATION, 100); beep.startTone(ToneGenerator.TONE_PROP_BEEP); } catch (Exception e) { Log.e("SCAN RING", e.getMessage(), e); } } if (rawResult.getText().isEmpty()) { return; } ConnectivityManager cm = (ConnectivityManager) getContext().getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetwork = cm.getActiveNetworkInfo(); if (activeNetwork != null && activeNetwork.isConnectedOrConnecting()) { api.getProduct(rawResult.getText(), getActivity(), mScannerView, this); } else { Intent intent = new Intent(getActivity(), SaveProductOfflineActivity.class); intent.putExtra("barcode", rawResult.getText()); getActivity().startActivity(intent); getActivity().finish(); } }
@Override public void onCreate() { super.onCreate(); Log.i(TAG, "OnCreate"); toneGenerator = new ToneGenerator(AudioManager.STREAM_NOTIFICATION, 100); notificationManager = (NotificationManager)this.getSystemService(Context.NOTIFICATION_SERVICE); connectivityManager = (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE); // Location Update PI Intent locationUpdateIntent = new Intent(Constants.LOCATION_UPDATE); locationUpdatePI = PendingIntent.getBroadcast(this, 9001, locationUpdateIntent, PendingIntent.FLAG_UPDATE_CURRENT); registerReceiver(locationUpdateReceiver, new IntentFilter(Constants.LOCATION_UPDATE)); Intent detectedActivitiesIntent = new Intent(Constants.DETECTED_ACTIVITY_UPDATE); detectedActivitiesPI = PendingIntent.getBroadcast(this, 9002, detectedActivitiesIntent, PendingIntent.FLAG_UPDATE_CURRENT); registerReceiver(detectedActivitiesReceiver, new IntentFilter(Constants.DETECTED_ACTIVITY_UPDATE)); // Receivers for start/stop recording registerReceiver(startRecordingReceiver, new IntentFilter(Constants.START_RECORDING)); registerReceiver(stopRecordingReceiver, new IntentFilter(Constants.STOP_RECORDING)); registerReceiver(startAggressiveReceiver, new IntentFilter(Constants.CHANGE_AGGRESSIVE)); // Location criteria criteria = new Criteria(); criteria.setAltitudeRequired(false); criteria.setBearingRequired(false); criteria.setSpeedRequired(true); criteria.setCostAllowed(true); }
public void testTone() throws Exception { Log.d(TAG, "Creating tone generator ADT 10"); ToneGenerator toneGen = new ToneGenerator(AudioManager.STREAM_RING, ToneGenerator.MAX_VOLUME); toneGen.startTone(ToneGenerator.TONE_PROP_BEEP2); final long DELAYED = 1000; Thread.sleep(DELAYED); toneGen.stopTone(); toneGen.release(); Log.d(TAG, "Released tone generator"); }
@Override public void onCreate() { super.onCreate(); toneGenerator = new ToneGenerator(AudioManager.STREAM_NOTIFICATION, 100); // Receiver for actions registerActionReceiver(); }
@Override public void onLongPress(final LatLong tapLatLong, final Point thisXY, final Point tapXY) { Toast.makeText(this.getActivity(), this.getActivity().getString(R.string.saved_waypoint) + "\n" + tapLatLong.toString(), Toast.LENGTH_LONG).show(); final DataHelper dbHelper = new DataHelper(getActivity().getApplicationContext()); final PositionRecord pos = new PositionRecord(GeometryUtils.toLocation(tapLatLong), mSessionId, RadioBeacon.PROVIDER_USER_DEFINED, true); dbHelper.storePosition(pos); // beep once point has been saved ToneGenerator toneG = new ToneGenerator(AudioManager.STREAM_ALARM, 100); toneG.startTone(ToneGenerator.TONE_CDMA_ALERT_CALL_GUARD, 200); }
/** * Constructor for SdServer class - does not do much! */ public SdServer() { super(); Log.v(TAG, "SdServer Created"); mSdData = new SdData(); mToneGenerator = new ToneGenerator(AudioManager.STREAM_ALARM, 100); }
/** * beep for duration milliseconds, but only if mAudibleAlarm is set. */ private void beep(int duration) { if (mToneGenerator != null) { mToneGenerator.startTone(ToneGenerator.TONE_CDMA_ALERT_CALL_GUARD, duration); Log.v(TAG, "beep()"); } else { mUtil.showToast("Warming mToneGenerator is null - not beeping!!!"); Log.v(TAG, "beep() - Warming mToneGenerator is null - not beeping!!!"); mUtil.writeToSysLogFile("SdServer.beep() - mToneGenerator is null???"); } }
@Override public void onCreate(Bundle savedInstanceState) { Log.i(TAG, "%% onCreate"); super.onCreate(savedInstanceState); if (getArguments() != null) { mParam1 = getArguments().getString(ARG_PARAM1); mParam2 = getArguments().getString(ARG_PARAM2); } toneGenerator = new ToneGenerator(AudioManager.STREAM_MUSIC, 100); }
@Override public boolean onKeyDown(int keyCode,KeyEvent event){ super.onKeyDown(keyCode, event); if(keyCode== KeyEvent.KEYCODE_DPAD_CENTER){ final ToneGenerator tg = new ToneGenerator(AudioManager.STREAM_NOTIFICATION, 100); tg.startTone(ToneGenerator.TONE_PROP_BEEP); mCraftARCamera.takePicture(); return true; } return false; }
public void onAutoFocus( boolean focused, android.hardware.Camera camera) { mFocusCallbackTime = System.currentTimeMillis(); mAutoFocusTime = mFocusCallbackTime - mFocusStartTime; Log.v(TAG, "mAutoFocusTime = " + mAutoFocusTime + "ms"); if (mFocusState == FOCUSING_SNAP_ON_FINISH) { // Take the picture no matter focus succeeds or fails. No need // to play the AF sound if we're about to play the shutter // sound. if (focused) { mFocusState = FOCUS_SUCCESS; } else { mFocusState = FOCUS_FAIL; } mImageCapture.onSnap(); } else if (mFocusState == FOCUSING) { // User is half-pressing the focus key. Play the focus tone. // Do not take the picture now. ToneGenerator tg = mFocusToneGenerator; if (tg != null) { tg.startTone(ToneGenerator.TONE_PROP_BEEP2); } if (focused) { mFocusState = FOCUS_SUCCESS; } else { mFocusState = FOCUS_FAIL; } } else if (mFocusState == FOCUS_NOT_STARTED) { // User has released the focus key before focus completes. // Do nothing. } updateFocusIndicator(); }
private void initializeFocusTone() { // Initialize focus tone generator. try { mFocusToneGenerator = new ToneGenerator( AudioManager.STREAM_SYSTEM, FOCUS_BEEP_VOLUME); } catch (Throwable ex) { Log.w(TAG, "Exception caught while creating tone generator: ", ex); mFocusToneGenerator = null; } }
/** * To report an event, we must be within certain location of the event occurance * @param e */ public void notifyCrime(Event e) { // prepare intent which is triggered if the // notification is selected NotificationManager notificationManager = (NotificationManager) mContext.getSystemService(Service.NOTIFICATION_SERVICE); /* * Alert! * Make intent to MainActitivty, and send info about this */ Intent intent = new Intent(mContext, MainActivity.class); intent.putExtra("location", e.lon + "," + e.lat); intent.putExtra("id", e.id); PendingIntent pIntent = PendingIntent.getActivity(mContext, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Builder builder = new NotificationCompat.Builder(mContext) .setSmallIcon(CrimeAdapter.getIconResource(e.type)) .setContentTitle(e.type) .setAutoCancel(true) .setContentIntent(pIntent) .setContentText( ((float)Math.round(e.getDistance() * 10.f) / 10.f) + " " + mContext.getString(R.string.miles_away)); Notification n = builder.build(); notificationManager.notify((int)e.id, n); // also make a tone to alert the user final ToneGenerator tg = new ToneGenerator(AudioManager.STREAM_NOTIFICATION, 100); tg.startTone(ToneGenerator.TONE_PROP_BEEP); }
@Override public void onCodeScanned(String contents) { Log.d(TAG, "Code Scanned: " + contents); // Beep final ToneGenerator tg = new ToneGenerator(AudioManager.STREAM_NOTIFICATION, 100); tg.startTone(ToneGenerator.TONE_PROP_BEEP); // Intent data = new Intent(); data.putExtra(kActivityResult_ScannedContents, contents); setResult(RESULT_OK, data); finish(); }