@Override public void onScanCompleted(String path, Uri uri) { beeper.startTone(ToneGenerator.TONE_PROP_NACK); } }
RecordingSession(Context ctxt, RecordingConfig config, MediaProjection projection) { this.ctxt=ctxt.getApplicationContext(); this.config=config; this.projection=projection; this.beeper=new ToneGenerator( AudioManager.STREAM_NOTIFICATION, 100); output=new File(ctxt.getExternalFilesDir(null), "andcorder.mp4"); output.getParentFile().mkdirs(); }
@Override public void onReadyForSpeech(Bundle params) { Log.d("SpeechRecognizer", "Ready"); if (beepOnReady && !hasBeeped) { Log.d("SpeechRecognizer", "Beeping"); hasBeeped = true; if (beepOnBluetooth) { final ToneGenerator tg = new ToneGenerator(6, 100); tg.startTone(ToneGenerator.TONE_PROP_BEEP); } else { Vibrator vibe = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE) ; vibe.vibrate(50); } }
/** * Stop the tone if it is played. */ private void stopTone() { // if local tone playback is disabled, just return. if (!mDTMFToneEnabled) { return; } synchronized (mToneGeneratorLock) { if (mToneGenerator == null) { Log.w(TAG, "stopTone: mToneGenerator == null"); return; } mToneGenerator.stopTone(); } }
@Override public void onStop() { super.onStop(); synchronized (mToneGeneratorLock) { if (mToneGenerator != null) { mToneGenerator.release(); mToneGenerator = null; } } if (mClearDigitsOnStop) { mClearDigitsOnStop = false; clearDialpad(); } }
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; } } } };
ToneGenerator toneG = new ToneGenerator(AudioManager.STREAM_ALARM, 100); toneG.startTone(ToneGenerator.TONE_CDMA_ALERT_CALL_GUARD, 200);
@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(); }
public void play () throws IOException { tg.startTone(ToneGenerator.TONE_CDMA_DIAL_TONE_LITE); try { Thread.sleep(300); } catch (InterruptedException e) { e.printStackTrace(); } tg.stopTone(); // if (audioManager.getStreamVolume(AudioManager.STREAM_ALARM) != 0) { // mMediaPlayer.reset(); // // mMediaPlayer.setAudioStreamType(AudioManager.STREAM_ALARM); // mMediaPlayer.prepare(); // mMediaPlayer.setLooping(false); // mMediaPlayer.start(); // } } }
private AudioToneMaker() { tone_gen = new ToneGenerator(AudioManager.STREAM_MUSIC, 100); }
final ToneGenerator tg = new ToneGenerator(AudioManager.STREAM_NOTIFICATION, 100); tg.startTone(ToneGenerator.TONE_PROP_BEEP);
@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); }
AudioManager am = (AudioManager) getSystemService(Context.AUDIO_SERVICE); int volume_level= am.getStreamVolume(AudioManager.STREAM_RING); // Highest Ring volume level is 7, lowest is 0 final ToneGenerator mToneGenerator = new ToneGenerator(AudioManager.STREAM_MUSIC, volume_level * 14); // Raising volume to 100% (For eg. 7 * 14 ~ 100) mToneGenerator.stopTone(); mToneGenerator.startTone(ToneGenerator.TONE_DTMF_1, 100); // play sound for 100ms
private AppState() { mListeners = new ArrayList<IDataListener>(); raceResults = new ArrayList<ArrayList<LapResult>>(); deviceStates = new ArrayList<DeviceState>(); deviceTransmissionStates = new ArrayList<Boolean>(); mToneGenerator = new ToneGenerator(AudioManager.STREAM_MUSIC, ToneGenerator.MAX_VOLUME); mBatteryMonitorHandler = new Handler() { public void handleMessage(Message msg) { AppState app = AppState.getInstance(); if (app.isConnected && app.isLiPoMonitorEnabled && app.raceState != null && !app.raceState.isStarted) { AppState.getInstance().sendBtCommand("R*v"); } sendEmptyMessageDelayed(0, BATTERY_CHECK_INTERVAL); } }; mBatteryNotifyHandler = new Handler() { public void handleMessage(Message msg) { AppState app = AppState.getInstance(); if (app.isConnected && app.isLiPoMonitorEnabled) { if (batteryPercentage <= 10) { speakMessage(R.string.battery_status_critical); } else if (batteryPercentage <= 20){ speakMessage(R.string.battery_status_low); } } sendEmptyMessageDelayed(0, BATTERY_WARN_INTERVAL); } }; raceState = new RaceState(false, DEFAULT_MIN_LAP_TIME, DEFAULT_LAPS_TO_GO); }
@Override public int onStartCommand(Intent i, int flags, int startId) { if (i.getAction()==null) { resultCode=i.getIntExtra(EXTRA_RESULT_CODE, 1337); resultData=i.getParcelableExtra(EXTRA_RESULT_INTENT); foregroundify(); } else if (ACTION_RECORD.equals(i.getAction())) { if (resultData!=null) { startCapture(); } else { Intent ui= new Intent(this, MainActivity.class) .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(ui); } } else if (ACTION_SHUTDOWN.equals(i.getAction())) { beeper.startTone(ToneGenerator.TONE_PROP_NACK); stopForeground(true); stopSelf(); } return(START_NOT_STICKY); }
@Override public void onStart() { Trace.beginSection(TAG + " onStart"); super.onStart(); // if the mToneGenerator creation fails, just continue without it. It is // a local audio signal, and is not as important as the dtmf tone itself. final long start = System.currentTimeMillis(); synchronized (mToneGeneratorLock) { if (mToneGenerator == null) { try { mToneGenerator = new ToneGenerator(DIAL_TONE_STREAM_TYPE, TONE_RELATIVE_VOLUME); } catch (RuntimeException e) { Log.w(TAG, "Exception caught while creating local tone generator: " + e); mToneGenerator = null; } } } final long total = System.currentTimeMillis() - start; if (total > 50) { Log.i(TAG, "Time for ToneGenerator creation: " + total); } Trace.endSection(); };