package kr.samsa;
import java.io.DataOutputStream;
import java.io.IOException;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class samsa extends Activity implements View.OnClickListener{
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.button);
Button btn1 = (Button)findViewById(R.id.btn1);
Button btn3 = (Button)findViewById(R.id.btn3);
btn1.setOnClickListener(this);
btn3.setOnClickListener(this);
}
public void onClick(View v) {
Process p;
try {
p = Runtime.getRuntime().exec("명령어1");
// Attempt to write a file to a root-only
DataOutputStream os = new DataOutputStream(p.getOutputStream());
os.writeBytes("명령어1");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}}
public void onClick1(View v1) {
Process p2;
try {
p2 = Runtime.getRuntime().exec("명령어2");
// Attempt to write a file to a root-only
DataOutputStream os = new DataOutputStream(p2.getOutputStream());
os.writeBytes("명령어2");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}}}
보시면 이렇게 버튼 2개를 클릭리스너로만들었느데
btn1 의 버튼 리스너 기능과 btn3 버튼 리스너기능이 겹쳐버리는 현상이 나타납니다..
골치아픕니다.. 도와주세요 ㅠ