Java 类android.media.ToneGenerator 实例源码

项目:ActivityMonitor    文件:RecorderService.java   
@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);
}
项目:RobotCA    文件:HUDFragment.java   
/**
 * '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);
        }
    }
}
项目:cordova-plugin-quintech-background-geolocation    文件:AbstractLocationProvider.java   
/**
 * 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);
}
项目:here-android-sdk-examples    文件:MyASR.java   
@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;
        }
    }
}
项目:JARVIS    文件:HUDFragment.java   
/**
 * '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);
        }
    }
}
项目:trust_net    文件:AAboutMeEdit.java   
@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();
}
项目:trust_net    文件:AConfirmOther.java   
@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;
}
项目:Tiresias    文件:PointCloudActivity.java   
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);
}
项目:cordova-plugin-mauron85-background-geolocation-phonegapbuild    文件:AbstractLocationService.java   
/**
 * 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);
}
项目:OpenFit    文件:OpenFitService.java   
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;
        }
    }
}
项目:cordova-plugin-passive-geolocation-service    文件:PassiveGeolocationService.java   
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);
}
项目:En-Garde    文件:MainActivity.java   
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;
    }
}
项目:Flyver-Apps    文件:BatteryStatus.java   
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);
            }
        }

    }
}
项目:craftar-example-glass    文件:FinderActivity.java   
@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;
}
项目:org.numixproject.torch    文件:MainActivity.java   
@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();
    }
    }
项目:org.numixproject.torch    文件:MainActivity.java   
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();
    }
}
项目:org.numixproject.torch    文件:MainActivity.java   
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();
    }
}
项目:alert    文件:MainActivity.java   
@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);
}
项目:PhoneFoneFun    文件:MainActivity.java   
@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();
}
项目:TwistyTimer    文件:CountdownWarning.java   
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);
}
项目:fitTimer    文件:SoundMaker.java   
@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();
}
项目:TUI-ConsoleLauncher    文件:beep.java   
@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;
}
项目:velociraptor    文件:Utils.java   
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) {
    }
}
项目:AstroSmash    文件:AstroSmashLauncher.java   
public static void playGameOverSound() {
    if (AstroSmashSettings.sound) {
        new Thread(new Runnable() {

            @Override
            public void run() {
                toneGenerator.startTone(ToneGenerator.TONE_CDMA_PRESSHOLDKEY_LITE);
            }

        }).start();
    }
}
项目:DroidMeter    文件:SerialConsoleActivity.java   
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());

}
项目:nur_sample_android    文件:TraceTagController.java   
@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();
        }
    }
}
项目:reaction-test    文件:UtilsRG.java   
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");
    }
}
项目:openfoodfacts-androidapp    文件:BarCodeScannerFragment.java   
@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();
    }
}
项目:cordova-background-geolocation-services    文件:BackgroundLocationUpdateService.java   
@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);
}
项目:VP8_H264_HW_ENC_Q_COMPARE    文件:MainActivity.java   
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");
    }
项目:cordova-plugin-mauron85-background-geolocation-phonegapbuild    文件:AbstractLocationService.java   
@Override
public void onCreate() {
    super.onCreate();
    toneGenerator = new ToneGenerator(AudioManager.STREAM_NOTIFICATION, 100);

    // Receiver for actions
    registerActionReceiver();
}
项目:radiocells-scanner-android    文件:MapViewActivity.java   
@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);
}
项目:Android_Pebble_SD    文件:SdServer.java   
/**
 * 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);
}
项目:Android_Pebble_SD    文件:SdServer.java   
/**
 * 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???");
    }
}
项目:restcomm-android-sdk    文件:KeypadFragment.java   
@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);
}
项目:craftar-example-glass    文件:SingleShotActivity.java   
@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;
}
项目:AndroidMedia    文件:Camera.java   
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();
}
项目:AndroidMedia    文件:Camera.java   
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;
    }
}
项目:alerttown    文件:NotificationBar.java   
/**
 * 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);

}
项目:Bluefruit_LE_Connect_Android    文件:MqttUartSettingsCodeReaderActivity.java   
@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();
}