本文整理汇总了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);
}
}
}
示例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);
}
示例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;
}
}
}
示例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();
}
示例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;
}
示例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);
}
示例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;
}
}
}
示例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;
}
}
示例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);
}
}
}
}
示例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;
}
示例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();
}
}
示例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();
}
}
示例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();
}
}