매일코딩/안드로이드
[안드로이드 기초] 인텐트로 전화걸기 기능 실행하기
인생여희
2017. 8. 15. 12:00
반응형
인텐트로 전화걸기 기능 실행하기
#전화걸기 화면
#소스
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | package me.happygate.myapplication009; import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.widget.Button; import android.widget.EditText; public class MainActivity extends AppCompatActivity { EditText editText; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //에딧텍스트 객체 editText=(EditText)findViewById(R.id.editText); //버튼 객체 Button button=(Button)findViewById(R.id.button); //버튼 클릭 button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //텍스트 객체의 데이터 값을 가져온다. String receiver =editText.getText().toString(); //인텐트 객체 생성 //인텐트로 전화 걸기 옵션 선언 //위에서 받은 전화번호 데이터 넣어주기 Intent intent =new Intent(Intent.ACTION_DIAL, Uri.parse("tel:"+ receiver)); //실행 startActivity(intent); } }); } } | cs |
반응형