Example usage for android.media ToneGenerator TONE_DTMF_4

List of usage examples for android.media ToneGenerator TONE_DTMF_4

Introduction

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

Prototype

int TONE_DTMF_4

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

Click Source Link

Document

DTMF tone for key 4: 1209Hz, 770Hz, 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:/*from   w w  w . java 2 s  . co  m*/
        return "";
    }
}

From source file:Main.java

/** Returns the tone type that the string character represents. If input is
 * empty, then returns -1. *///  www . jav a  2 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.
}