package com.example.hellow;
import android.app.Activity; import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.EditText;
public class IntentUseActivity extends Activity{ //암시적 Intent 사용 예제... @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.intent_use1); final EditText phone = (EditText)findViewById(R.id.phone); Button call = (Button)findViewById(R.id.call); call.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String phoneNumber = phone.getText().toString(); Intent intent = new Intent(); intent.setAction(android.content.Intent.ACTION_DIAL); intent.setData(Uri.parse("tel:" + phoneNumber)); startActivity(intent); } }); } }
-------------------------------------------------------------------------------------------------
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="전화번호 : " />
<EditText android:id="@+id/phone" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="01012349999"> <requestFocus /> </EditText> </LinearLayout>
<Button android:id="@+id/call" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="전화걸기" />
</LinearLayout> |