main.xml

<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" /> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/inputphonenumber" /> <EditText android:id="@+id/phonenumber" android:layout_width="fill_parent" android:layout_height="wrap_content" android:phoneNumber="true" /> <Button android:id="@+id/btn_call" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/call" /> </LinearLayout>

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.wide.phone" android:versionCode="1" android:versionName="1.0"> <uses-sdk android:minSdkVersion="8" /> <!--添加可以向外拨打电话的权限 --> <uses-permission android:name="android.permission.CALL_PHONE"></uses-permission> <application android:icon="@drawable/icon" android:label="@string/app_name"> <activity android:name=".phoneAcitivity" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest>

phoneActivity.java

package com.wide.phone; import android.app.Activity; import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.EditText; public class phoneAcitivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Button btn_call = (Button) findViewById(R.id.btn_call); btn_call.setOnClickListener(new OnClickListener() { public void onClick(View v) { // TODO Auto-generated method stub EditText et_phonenumber = (EditText)findViewById(R.id.phonenumber); String number = et_phonenumber.getText().toString(); //用intent启动拨打电话 Intent intent = new Intent(Intent.ACTION_CALL,Uri.parse("tel:"+number)); startActivity(intent); } }); } }

更多相关文章

  1. Android 权限全集
  2. Android中通过代码检测系统是否有root权限
  3. android 9.0 SD卡权限问题 文件管理器没有权限
  4. 关于Android动态权限的一些疑问
  5. Android 网络权限配置
  6. Android App 权限一点知识
  7. android app请求获取root权限
  8. Android 权限控制代码分析

随机推荐

  1. android 巧用动画使您app风骚起来
  2. android:singleLine="true",[...]没有全
  3. 简单明了的分析Android触摸事件,看完再也
  4. Android的MediaPlayer架构介绍
  5. Android(安卓)activity 详解一:activity的
  6. ACtivity布局之相对布局基本用法
  7. 一个android工程的运行过程
  8. Android(安卓)file类使用详解-SDcard
  9. Android布局中的常用属性小结
  10. Android百度地图(六):百度地图POI检索,行