Skip to content

Instantly share code, notes, and snippets.

@YuuichiAkagawa
Created May 19, 2012 15:46
Show Gist options
  • Save YuuichiAkagawa/2731286 to your computer and use it in GitHub Desktop.
Save YuuichiAkagawa/2731286 to your computer and use it in GitHub Desktop.
delonkun
package org.ammlab.android.delonkun;
import android.app.Activity;
import android.media.*;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.LinearLayout;
public class DelonkunActivity extends Activity {
ToneGenerator toneGenerator;
@Override public void onCreate(Bundle savedInstanceState) {
toneGenerator = new
ToneGenerator(AudioManager.STREAM_SYSTEM,ToneGenerator.MAX_VOLUME);
super.onCreate(savedInstanceState);
LinearLayout layout = new LinearLayout(this);
LinearLayout layout1 = new LinearLayout(this);
LinearLayout layout2 = new LinearLayout(this);
LinearLayout layout3 = new LinearLayout(this);
layout.setOrientation(LinearLayout.VERTICAL);
layout1.setOrientation(LinearLayout.HORIZONTAL);
layout2.setOrientation(LinearLayout.HORIZONTAL);
layout3.setOrientation(LinearLayout.HORIZONTAL);
layout.addView(layout1);
layout.addView(layout2);
layout.addView(layout3);
setContentView(layout);
Button btn1 = new Button(this);
Button btn2 = new Button(this);
Button btn3 = new Button(this);
Button btn4 = new Button(this);
Button btn5 = new Button(this);
Button btn6 = new Button(this);
Button btn7 = new Button(this);
Button btn8 = new Button(this);
Button btn9 = new Button(this);
btn1.setText("LEFT");
btn2.setText("FWD");
btn3.setText("RIGHT");
btn4.setText("TURN L");
btn5.setText("STOP");
btn6.setText("TURN R");
btn7.setText("LEFT");
btn8.setText("BACK");
btn9.setText("RIGHT");
layout1.addView(btn1);
layout1.addView(btn2);
layout1.addView(btn3);
layout2.addView(btn4);
layout2.addView(btn5);
layout2.addView(btn6);
layout3.addView(btn7);
layout3.addView(btn8);
layout3.addView(btn9);
//Left Forward
btn1.setOnClickListener(new OnClickListener(){public void onClick(View v)
{toneGenerator.startTone(ToneGenerator.TONE_DTMF_4);}});
//Forward
btn2.setOnClickListener(new OnClickListener(){public void onClick(View v)
{toneGenerator.startTone(ToneGenerator.TONE_DTMF_5);}});
//Right Forward
btn3.setOnClickListener(new OnClickListener(){public void onClick(View v)
{toneGenerator.startTone(ToneGenerator.TONE_DTMF_1);}});
//Turn Left
btn4.setOnClickListener(new OnClickListener(){public void onClick(View v)
{toneGenerator.startTone(ToneGenerator.TONE_DTMF_6);}});
//STOP
btn5.setOnClickListener(new OnClickListener(){public void onClick(View v)
{toneGenerator.startTone(ToneGenerator.TONE_DTMF_D);}});
//Turn Right
btn6.setOnClickListener(new OnClickListener(){public void onClick(View v)
{toneGenerator.startTone(ToneGenerator.TONE_DTMF_9);}});
//Left Backword
btn7.setOnClickListener(new OnClickListener(){public void onClick(View v)
{toneGenerator.startTone(ToneGenerator.TONE_DTMF_8);}});
//Backword
btn8.setOnClickListener(new OnClickListener(){public void onClick(View v)
{toneGenerator.startTone(ToneGenerator.TONE_DTMF_0);}});
//Right Backword
btn9.setOnClickListener(new OnClickListener(){public void onClick(View v)
{toneGenerator.startTone(ToneGenerator.TONE_DTMF_2);}});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment