当前位置: 首页>>代码示例>>Java>>正文


Java ToneGenerator类代码示例

本文整理汇总了Java中android.media.ToneGenerator的典型用法代码示例。如果您正苦于以下问题:Java ToneGenerator类的具体用法?Java ToneGenerator怎么用?Java ToneGenerator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ToneGenerator类属于android.media包,在下文中一共展示了ToneGenerator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: warn

import android.media.ToneGenerator; //导入依赖的package包/类
/**
 * '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);
        }
    }
}
 
开发者ID:mtbii,项目名称:RobotCA,代码行数:20,代码来源:HUDFragment.java

示例2: startTone

import android.media.ToneGenerator; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:QuintechDevOps,项目名称:cordova-plugin-quintech-background-geolocation,代码行数:24,代码来源:AbstractLocationProvider.java

示例3: onHandleIntent

import android.media.ToneGenerator; //导入依赖的package包/类
@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);
}
 
开发者ID:apuder,项目名称:ActivityMonitor,代码行数:22,代码来源:RecorderService.java

示例4: onError

import android.media.ToneGenerator; //导入依赖的package包/类
@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;
        }
    }
}
 
开发者ID:heremaps,项目名称:here-android-sdk-examples,代码行数:17,代码来源:MyASR.java

示例5: onPostExecute

import android.media.ToneGenerator; //导入依赖的package包/类
@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();
}
 
开发者ID:UncleAndy,项目名称:trust_net,代码行数:22,代码来源:AAboutMeEdit.java

示例6: onPostExecute

import android.media.ToneGenerator; //导入依赖的package包/类
@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;
}
 
开发者ID:UncleAndy,项目名称:trust_net,代码行数:20,代码来源:AConfirmOther.java

示例7: playTone

import android.media.ToneGenerator; //导入依赖的package包/类
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);
}
 
开发者ID:kupoko,项目名称:Tiresias,代码行数:20,代码来源:PointCloudActivity.java

示例8: run

import android.media.ToneGenerator; //导入依赖的package包/类
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;
        }
    }
}
 
开发者ID:jareddlc,项目名称:OpenFit,代码行数:20,代码来源:OpenFitService.java

示例9: startTone

import android.media.ToneGenerator; //导入依赖的package包/类
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);
}
 
开发者ID:greensea,项目名称:cordova-plugin-passive-geolocation-service,代码行数:20,代码来源:PassiveGeolocationService.java

示例10: startTimer

import android.media.ToneGenerator; //导入依赖的package包/类
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;
    }
}
 
开发者ID:ethanmad,项目名称:En-Garde,代码行数:22,代码来源:MainActivity.java

示例11: calculateStatus

import android.media.ToneGenerator; //导入依赖的package包/类
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);
            }
        }

    }
}
 
开发者ID:flyver,项目名称:Flyver-Apps,代码行数:21,代码来源:BatteryStatus.java

示例12: onKeyDown

import android.media.ToneGenerator; //导入依赖的package包/类
@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;
}
 
开发者ID:Catchoom,项目名称:craftar-example-glass,代码行数:21,代码来源:FinderActivity.java

示例13: run

import android.media.ToneGenerator; //导入依赖的package包/类
@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();
    }
    }
 
开发者ID:numixproject,项目名称:org.numixproject.torch,代码行数:23,代码来源:MainActivity.java

示例14: longSOS

import android.media.ToneGenerator; //导入依赖的package包/类
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();
    }
}
 
开发者ID:numixproject,项目名称:org.numixproject.torch,代码行数:22,代码来源:MainActivity.java

示例15: shortSOS

import android.media.ToneGenerator; //导入依赖的package包/类
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();
    }
}
 
开发者ID:numixproject,项目名称:org.numixproject.torch,代码行数:22,代码来源:MainActivity.java


注:本文中的android.media.ToneGenerator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。