本文整理匯總了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();
}
}