本文整理匯總了Java中android.media.ToneGenerator.startTone方法的典型用法代碼示例。如果您正苦於以下問題:Java ToneGenerator.startTone方法的具體用法?Java ToneGenerator.startTone怎麽用?Java ToneGenerator.startTone使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.media.ToneGenerator
的用法示例。
在下文中一共展示了ToneGenerator.startTone方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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);
}
示例2: 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();
}
示例3: 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;
}
示例4: 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);
}
示例5: 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;
}
}
}
示例6: 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);
}
}
}
}
示例7: 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;
}
示例8: 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();
}
}
示例9: 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();
}
}
示例10: 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();
}
}
示例11: taskFailed
import android.media.ToneGenerator; //導入方法依賴的package包/類
@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);
}
示例12: run
import android.media.ToneGenerator; //導入方法依賴的package包/類
@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();
}
示例13: exec
import android.media.ToneGenerator; //導入方法依賴的package包/類
@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;
}
示例14: playTone
import android.media.ToneGenerator; //導入方法依賴的package包/類
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) {
}
}
示例15: parseReceivedData
import android.media.ToneGenerator; //導入方法依賴的package包/類
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());
}