package com.android.ToneGen;
import android.app.Activity;
import android.media.AudioManager;
import android.media.ToneGenerator;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
public class ToneGen extends Activity {
ToneGenerator tone;
Button btnSend;
EditText editTone;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
tone = new ToneGenerator(AudioManager.STREAM_DTMF, 100);
btnSend=(Button)findViewById(R.id.btnSend);
editTone= (EditText)findViewById(R.id.editTone);
btnSend.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int no=Integer.parseInt(editTone.getText().toString());
tone.startTone(no,2000);
}
});
}
}
thanks.
ReplyDeletei got a versions that only alows.
tone.startTone(no);
so i needed a tone.stopTone();
now it works. Fine.
Hey dude, Can any one give simple complete code of Tone generator with designing xml as well.
ReplyDeletebecause Iam not getting it properly.