Example usage for android.media ToneGenerator TONE_DTMF_0

List of usage examples for android.media ToneGenerator TONE_DTMF_0

Introduction

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

Prototype

int TONE_DTMF_0

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

Click Source Link

Document

DTMF tone for key 0: 1336Hz, 941Hz, continuous

Usage

From source file:Main.java

/** Returns a string character that represents the tone type. if input is
 * invalid, then returns an empty string. */
public static String getStringFromToneType(int toneType) {
    switch (toneType) {
    case ToneGenerator.TONE_DTMF_0:
        return "0";
    case ToneGenerator.TONE_DTMF_1:
        return "1";
    case ToneGenerator.TONE_DTMF_2:
        return "2";
    case ToneGenerator.TONE_DTMF_3:
        return "3";
    case ToneGenerator.TONE_DTMF_4:
        return "4";
    case ToneGenerator.TONE_DTMF_5:
        return "5";
    case ToneGenerator.TONE_DTMF_6:
        return "6";
    case ToneGenerator.TONE_DTMF_7:
        return "7";
    case ToneGenerator.TONE_DTMF_8:
        return "8";
    case ToneGenerator.TONE_DTMF_9:
        return "9";
    case ToneGenerator.TONE_DTMF_A:
        return "A";
    case ToneGenerator.TONE_DTMF_B:
        return "B";
    case ToneGenerator.TONE_DTMF_C:
        return "C";
    case ToneGenerator.TONE_DTMF_D:
        return "D";
    case ToneGenerator.TONE_DTMF_P:
        return "#";
    case ToneGenerator.TONE_DTMF_S:
        return "*";
    default:/* w ww .ja  v a 2  s  .  c  om*/
        return "";
    }
}

From source file:Main.java

/** Returns the tone type that the string character represents. If input is
 * empty, then returns -1. *//*from   ww w .j a v  a2  s .  c o  m*/
public static int getToneTypeFromString(String toneString) {
    if (TextUtils.isEmpty(toneString)) {
        return -1;
    }

    if (toneString.equalsIgnoreCase("0")) {
        return ToneGenerator.TONE_DTMF_0;
    } else if (toneString.equalsIgnoreCase("1")) {
        return ToneGenerator.TONE_DTMF_1;
    } else if (toneString.equalsIgnoreCase("2")) {
        return ToneGenerator.TONE_DTMF_2;
    } else if (toneString.equalsIgnoreCase("3")) {
        return ToneGenerator.TONE_DTMF_3;
    } else if (toneString.equalsIgnoreCase("4")) {
        return ToneGenerator.TONE_DTMF_4;
    } else if (toneString.equalsIgnoreCase("5")) {
        return ToneGenerator.TONE_DTMF_5;
    } else if (toneString.equalsIgnoreCase("6")) {
        return ToneGenerator.TONE_DTMF_6;
    } else if (toneString.equalsIgnoreCase("7")) {
        return ToneGenerator.TONE_DTMF_7;
    } else if (toneString.equalsIgnoreCase("8")) {
        return ToneGenerator.TONE_DTMF_8;
    } else if (toneString.equalsIgnoreCase("9")) {
        return ToneGenerator.TONE_DTMF_9;
    } else if (toneString.equalsIgnoreCase("A")) {
        return ToneGenerator.TONE_DTMF_A;
    } else if (toneString.equalsIgnoreCase("B")) {
        return ToneGenerator.TONE_DTMF_B;
    } else if (toneString.equalsIgnoreCase("C")) {
        return ToneGenerator.TONE_DTMF_C;
    } else if (toneString.equalsIgnoreCase("D")) {
        return ToneGenerator.TONE_DTMF_D;
    } else if (toneString.equalsIgnoreCase("#")) {
        return ToneGenerator.TONE_DTMF_P;
    } else if (toneString.equalsIgnoreCase("*")) {
        return ToneGenerator.TONE_DTMF_S;
    }
    return ToneGenerator.TONE_DTMF_0; // Error if code reaches here.
}

From source file:com.abcvoipsip.ui.dialpad.DialerFragment.java

public void onClick(View view) {
    // ImageButton b = null;
    int view_id = view.getId();

    if (view_id == R.id.button0) {
        dialFeedback.giveFeedback(ToneGenerator.TONE_DTMF_0);
        keyPressed(KeyEvent.KEYCODE_0);
    } else if (view_id == R.id.switchTextView) {
        // Set as text dialing if we are currently digit dialing
        setTextDialing(isDigit);// ww w.jav a2  s .  c om
    } else if (view_id == R.id.digitsText) {
        if (digits.length() != 0) {
            digits.setCursorVisible(true);
        }
    }
}