php除了做网站还能做什么,装修设计灵感网站,网站安全 扫描,微信小程序开发需要多少钱?众所周知,对于一个手机,能拨打电话是其最重要也是最常用的一个功能.而在Android里是怎么样实现拨打电话的程序呢?我在这里写了一个简单的拨打电话的Demo,供大家参考.一共分为5个步骤.Step 1:新建一个Android工程,命名为phoneCallDemo.Step 2:设计程序的界面,打开main.xml把内容…众所周知,对于一个手机,能拨打电话是其最重要也是最常用的一个功能.而在Android里是怎么样实现拨打电话的程序呢?我在这里写了一个简单的拨打电话的Demo,供大家参考.一共分为5个步骤.Step 1:新建一个Android工程,命名为phoneCallDemo.Step 2:设计程序的界面,打开main.xml把内容修改如下:android:layout_widthfill_parentandroid:layout_heightfill_parentandroid:orientationvertical android:layout_widthfill_parentandroid:layout_heightwrap_contentandroid:textSize15dipandroid:textstring/hello /android:layout_widthfill_parentandroid:layout_heightwrap_contentandroid:phoneNumbertrue/android:textcallandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:gravitycenter_horizontal/Step 3:增加拨打电话的权限,打开AndroidManifest.xml,修改代码如下:packagecom.android.testandroid:versionCode1android:versionName1.0android:labelstring/app_nameStep 4:主程序phoneCallDemo.java代码如下:package com.ecjtu.lp;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;import android.widget.Toast;public class PhoneCallDemoActivity extends Activity {/** Called when the activity is first created. */private EditText edit;private Button btn;Overridepublic void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.main);edit (EditText) findViewById(R.id.edit);btn (Button) findViewById(R.id.btn);btn.setOnClickListener(new OnClickListener() {Overridepublic void onClick(View v) {String input edit.getText().toString();//如果输入不为空创建打电话的Intentif(input.trim().length() ! 0){Intent phoneIntent new Intent(android.intent.action.CALL, Uri.parse(tel:input));startActivity(phoneIntent);}else{Toast.makeText(PhoneCallDemoActivity.this, 输入的电话号码不能为空, Toast.LENGTH_LONG).show();}}});}}Step 5:运行代码,效果如下: