Example usage for android.media ToneGenerator TONE_PROP_BEEP

List of usage examples for android.media ToneGenerator TONE_PROP_BEEP

Introduction

In this page you can find the example usage for android.media ToneGenerator TONE_PROP_BEEP.

Prototype

int TONE_PROP_BEEP

To view the source code for android.media ToneGenerator TONE_PROP_BEEP.

Click Source Link

Document

Proprietary tone, general beep: 400Hz+1200Hz, 35ms ON

Usage

From source file:com.marianhello.bgloc.AbstractLocationProvider.java

/**
 * Plays debug sound// ww w  . jav  a  2 s  .c  o m
 * @param name tone
 */
protected void startTone(Tone name) {
    if (toneGenerator == null)
        return;

    int tone = 0;
    int duration = 1000;

    switch (name) {
    case BEEP:
        tone = ToneGenerator.TONE_PROP_BEEP;
        break;
    case BEEP_BEEP_BEEP:
        tone = ToneGenerator.TONE_CDMA_CONFIRM;
        break;
    case LONG_BEEP:
        tone = ToneGenerator.TONE_CDMA_ABBR_ALERT;
        break;
    case DOODLY_DOO:
        tone = ToneGenerator.TONE_CDMA_ALERT_NETWORK_LITE;
        break;
    case CHIRP_CHIRP_CHIRP:
        tone = ToneGenerator.TONE_CDMA_ALERT_CALL_GUARD;
        break;
    case DIALTONE:
        tone = ToneGenerator.TONE_SUP_RINGTONE;
        break;
    }

    toneGenerator.startTone(tone, duration);
}

From source file:com.tenforwardconsulting.cordova.bgloc.AbstractLocationProvider.java

/**
 * Plays debug sound/*from  w  w  w  .j  a  va  2 s.  c  o  m*/
 * @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);
}

From source file:com.grupohqh.carservices.operator.ReadTagActivity.java

private void readTag() {
    runOnUiThread(new Runnable() {
        int scantimes = 25;
        String tagId;//w  w w.  j  av a 2s. c  o  m
        ToneGenerator tg = new ToneGenerator(AudioManager.STREAM_MUSIC, 100);

        @Override
        public void run() {
            for (int i = 0; i < scantimes; i++) {
                MtiCmd mtiCmd = new CMD_Iso18k6cTagAccess.RFID_18K6CTagInventory(usbCommunication);
                CMD_Iso18k6cTagAccess.RFID_18K6CTagInventory finalCmd = (CMD_Iso18k6cTagAccess.RFID_18K6CTagInventory) mtiCmd;
                if (finalCmd.setCmd(CMD_Iso18k6cTagAccess.Action.StartInventory)) {
                    tagId = finalCmd.getTagId();
                    if (finalCmd.getTagNumber() > 0) {
                        tg.startTone(ToneGenerator.TONE_PROP_BEEP);
                        etEpc.setText(tagId);
                        break;
                    }
                }
            }
            if (!etEpc.getText().toString().equals(""))
                new HttpAsyncTask().execute(URL);
            else
                etEpc.setHint("No se encontro ningun TAG");
        }
    });
}

From source file:com.grupohqh.carservices.operator.ManipulateCarActivity.java

private void readTag() {
    runOnUiThread(new Runnable() {
        int scantimes = 25;
        String tagId;/*from   ww w.j  a  v  a2  s . c  om*/
        ToneGenerator tg = new ToneGenerator(AudioManager.STREAM_MUSIC, 100);

        @Override
        public void run() {
            for (int i = 0; i < scantimes; i++) {
                MtiCmd mtiCmd = new CMD_Iso18k6cTagAccess.RFID_18K6CTagInventory(usbCommunication);
                CMD_Iso18k6cTagAccess.RFID_18K6CTagInventory finalCmd = (CMD_Iso18k6cTagAccess.RFID_18K6CTagInventory) mtiCmd;
                if (finalCmd.setCmd(CMD_Iso18k6cTagAccess.Action.StartInventory)) {
                    tagId = finalCmd.getTagId();
                    if (finalCmd.getTagNumber() > 0) {
                        tg.startTone(ToneGenerator.TONE_PROP_BEEP);
                        etEPC.setText(tagId);
                        break;
                    }
                }
            }
            if (etEPC.getText().toString().equals(""))
                etEPC.setHint("No se encontro ningun TAG");
        }
    });
}

From source file:com.github.wakhub.monodict.activity.FlashcardActivity.java

private boolean autoPlayLoop() {
    Cursor cursor = listAdapter.getCursor();
    Card card = null;//w  w w  .java  2 s .  co m
    switch (autoPlayProgress) {
    case START:
        speechHelper.init();
        showAutoPlayAlertDialog();
        speechHelper.setOnUtteranceListener(this);
        cursor.moveToFirst();
        autoPlayProgress = AutoPlayProgress.WAIT_FOR_DISPLAY;
        try {
            card = new Card(cursor);
        } catch (CursorIndexOutOfBoundsException e) {
            activityHelper.showError(e);
            return false;
        }
        setAutoPlayCard(card);
        toneGenerator.startTone(ToneGenerator.TONE_PROP_ACK);
        activityHelper.sleep(2000);
        break;
    case WAIT_FOR_DISPLAY:
        autoPlayProgress = AutoPlayProgress.DISPLAY;
        activityHelper.sleep(500);
        speechHelper.speech(new Card(cursor).getDisplay());
        break;
    case WAIT_FOR_TRANSLATE:
        autoPlayProgress = AutoPlayProgress.TRANSLATE;
        String languageForTranslate = preferences.ttsLanguageForTranslate().get();
        Locale localeForTranslate = new Locale(languageForTranslate.substring(0, 2));

        activityHelper.sleep(500);
        try {
            card = new Card(cursor);
        } catch (CursorIndexOutOfBoundsException e) {
            activityHelper.showError(e);
            return false;
        }
        speechHelper.speech(card.getTranslate().substring(0, Math.min(card.getTranslate().length(), 100)),
                localeForTranslate, null);
        break;
    case WAIT_FOR_NEXT:
        cursor.moveToNext();
        setAutoPlayCard(new Card(cursor));
        autoPlayProgress = AutoPlayProgress.WAIT_FOR_DISPLAY;

        activityHelper.sleep(500);
        toneGenerator.startTone(ToneGenerator.TONE_PROP_BEEP);
        activityHelper.sleep(1000);
        break;
    case WAIT_FOR_STOP:
        stopAutoPlay();
        return false;
    }
    return true;
}

From source file:com.marianhello.cordova.bgloc.LocationUpdateService.java

/**
     * Plays debug sound//from  w w w .ja v a2  s. c  o  m
     * @param name
     */
    private 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);
    }

From source file:com.kaichaohulian.baocms.ecdemo.ui.chatting.ChattingFragment.java

/**
 * ??//w w w.  j a  v  a  2s.  c  o m
 */
protected void readyOperation() {
    computationTime = -1L;
    mRecordTipsToast = null;
    playTone(ToneGenerator.TONE_PROP_BEEP, TONE_LENGTH_MS);
    new Handler().postDelayed(new Runnable() {

        @Override
        public void run() {
            stopTone();
        }
    }, TONE_LENGTH_MS);
    vibrate(50L);
}

From source file:com.strathclyde.highlightingkeyboard.SoftKeyboardService.java

/**
 * handle the receipt of suggestions from the spell checker
 * colour the text in the editor as required
 * pass information to the keyboard view so it can draw the colour bar
 * initiate audio and haptic feedback as required
 *///from   ww w .  j  av a  2 s  . c om
@Override
public void onGetSuggestions(SuggestionsInfo[] results) {
    // TODO Auto-generated method stub
    int colortype = -1;
    final StringBuilder sb = new StringBuilder();

    if (updateSuggestionList) {
        updateSuggestionList = false;
        ArrayList<String> s = new ArrayList<String>();
        for (int i = 0; i < results.length; ++i) {
            final int length = results[i].getSuggestionsCount();
            for (int j = 0; j < length; ++j) {
                s.add(results[i].getSuggestionAt(j));
            }
        }
        updateSuggestionListWithSpellChecker(s);
    } else {

        for (int i = 0; i < results.length; ++i) {
            // Returned suggestions are contained in SuggestionsInfo

            final int len = results[i].getSuggestionsCount();
            sb.append("Suggestion Attribs: " + results[i].getSuggestionsAttributes());
            if ((results[i].getSuggestionsAttributes()
                    & SuggestionsInfo.RESULT_ATTR_IN_THE_DICTIONARY) == SuggestionsInfo.RESULT_ATTR_IN_THE_DICTIONARY) {
                sb.append("The word was found in the dictionary\n");
                mInputView.wordcompletedtype = 3;
            } else {

                if ((results[i].getSuggestionsAttributes()
                        & SuggestionsInfo.RESULT_ATTR_LOOKS_LIKE_TYPO) == SuggestionsInfo.RESULT_ATTR_LOOKS_LIKE_TYPO) {
                    if ((results[i].getSuggestionsAttributes()
                            & SuggestionsInfo.RESULT_ATTR_HAS_RECOMMENDED_SUGGESTIONS) == SuggestionsInfo.RESULT_ATTR_HAS_RECOMMENDED_SUGGESTIONS) {
                        colortype = 1; //yellow
                        mInputView.wordcompletedtype = 1;
                        sb.append("There are strong candidates for this word\n");
                        currentSession.nLowErrors++;
                    } else {
                        colortype = 2; //red
                        mInputView.wordcompletedtype = 2;
                        sb.append("The word looks like a typo\n");
                        currentSession.nHighErrors++;

                    }
                }

            }

            sb.append("\n--These are the suggestions--\n");
            for (int j = 0; j < len; ++j) {
                sb.append("," + results[i].getSuggestionAt(j));
            }
            sb.append(" (" + len + ")");
        }
        //Log.i("Spelling suggestions", sb.toString());

        //this comes after a word separator, hence just add 1 to the cursor
        SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());

        SpannableString text = new SpannableString(mComposingTemp);

        if (sharedPrefs.getBoolean("highlightwords", true)) {
            switch (colortype) {
            case 1:
                text.setSpan(new BackgroundColorSpan(small_err), 0, mComposingTemp.length(),
                        Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
                break;
            case 2:
                text.setSpan(new BackgroundColorSpan(big_err), 0, mComposingTemp.length(),
                        Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
                break;
            default:
                break;
            }
        }

        if (sharedPrefs.getBoolean("autocorrect", true) && mInputView.wordcompletedtype == 1) //handle autocorrection
        {
            SpannableString autoc = autocorrect(results);
            autocorrected_words.put(autoc.toString(), text.toString()); //autocorrected word, original input
            //Log.i("Autocorrecting","Key= "+autoc.toString()+", Value= "+text.toString());
            text = autoc;
            if (sharedPrefs.getBoolean("highlightwords", true))
                text.setSpan(new BackgroundColorSpan(autocorrect), 0, text.length(),
                        Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
            mInputView.wordcompletedtype = 4;
        } else //autocorrection is turned off
        {
            if (!sharedPrefs.getBoolean("autocorrect", true) && colortype >= 1) //a mistake word
            {
                //Log.i("OnGetSentenceSuggestions","Key= "+text.toString()+", Value= "+text.toString());
                //no autocorrects, just put the word in and itself as the replacement
                autocorrected_words.put(text.toString(), text.toString());
            }
        }

        if (sharedPrefs.getBoolean("vibrator", false)) {
            Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
            final int on_time = Integer.parseInt(sharedPrefs.getString("shortvibe", "35"));

            switch (mInputView.wordcompletedtype) {
            case 1: //small err
                // Vibrate for 300 milliseconds
                v.vibrate(on_time);
                break;
            case 2: //big err
                //v.vibrate(Integer.parseInt(sharedPrefs.getString("longvibe", "300")));
                v.vibrate(new long[] { 0, on_time, 200, on_time }, -1);
                break;
            case 4: //autocorr
                v.vibrate(on_time);
                break;
            default:
                break;

            }
        }

        if (sharedPrefs.getBoolean("audio", false)) {
            final ToneGenerator tg = new ToneGenerator(AudioManager.STREAM_NOTIFICATION, 100);
            switch (mInputView.wordcompletedtype) {
            case 1: //small err
                tg.startTone(ToneGenerator.TONE_PROP_BEEP);
                break;
            case 2: //big err
                tg.startTone(ToneGenerator.TONE_PROP_BEEP2);
                break;
            case 4: //autocorr
                tg.startTone(ToneGenerator.TONE_PROP_BEEP);
                break;
            default:
                break;

            }
        }

        mInputView.invalidateAllKeys();
        ic.commitText(text, 1);
        sendKey(wordSeparatorKeyCode);
        coreEngine.resetCoreString();
        updateCandidates();
    }

}

From source file:jmri.enginedriver.throttle.java

void GamepadFeedbackSound(boolean invalidAction) {
    if (mainapp.appIsFinishing) {
        return;/*  w  w  w  . j a v  a  2  s.  c  om*/
    }

    if (tg != null) {
        if (invalidAction)
            tg.startTone(ToneGenerator.TONE_PROP_NACK);
        else
            tg.startTone(ToneGenerator.TONE_PROP_BEEP);
    }
}