Android系统原本就为手机设计,所以,在android系统中的不论什么App中,仅仅要愿意,拨打指定电话很方便。

核心就是使用Intent跳转,指定请求Action为Intent.ACTION_CALL 就可以。

【源代码下载】 http://www.code4apk.com/android-code/178

核心代码例如以下:

1 Intent
intent = 
new Intent(Intent.ACTION_CALL,Uri.parse("tel:13888888888");

以下一起来实现这个功能:

第1步:新建一个activity :DialerAndMsgActivity

package com.android.dev;

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 DialerAndMsgActivity extends Activity {
private Button dialerButton;
private EditText editTextPhoneNum; /** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main); dialerButton = (Button) findViewById(R.id.Button_Dialer);
editTextPhoneNum = (EditText) findViewById(R.id.EditText_PhoneNum); dialerButton.setOnClickListener(new View.OnClickListener(){ public void onClick(View arg0) {
Intent intent = new Intent(Intent.ACTION_CALL,Uri.parse("tel:"+
editTextPhoneNum.getText()));
DialerAndMsgActivity.this.startActivity(intent);
} });
}
}

第2步:改动配置文件: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:id="@+id/TextView_Phone"
android:layout_width="fill_parent"
android:layout_height="wrap_content" android:text="@string/tell_tile" /> <EditText android:id="@+id/EditText_PhoneNum"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<Button android:id="@+id/Button_Dialer"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:text="@string/button_call"/>
</LinearLayout>

第3步:在配置文件AndroidManifest.xml中加入拨号支持

1 <uses-permission android:name="android.permission.CALL_PHONE"></uses-permission>

第4步调试执行:

android拨打电话

android拨打电话

【源代码下载】 http://www.code4apk.com/android-code/178

Android中怎样调用拨打电话?的更多相关文章

  1. 【Android】Android开发初学者实现拨打电话的功能,拨打电话app小demo实现

    作者:程序员小冰,GitHub主页:https://github.com/QQ986945193 新浪微博:http://weibo.com/mcxiaobing 首先先给大家看一下最终实现的效果: ...

  2. Android点击按钮拨打电话

    代码改变世界 Android点击按钮拨打电话 public void callPhone(String str) { Intent intent=new Intent(); intent.setAct ...

  3. Android开发手记(15) 拨打电话和收发短信

    1.Intent简介 Android组价之间的通信,由Intent来协助完成.Intent负责对应用中一次操作的动作.动作涉及数据.附加数据进行描述,Android则根据此Intent的描述,负责找到 ...

  4. Android无需申请权限拨打电话

    Android打电话有两种实现方法: 第一种方法,拨打电话跳转到拨号界面.源代码如下: Intent intent = new Intent(Intent.ACTION_DIAL); Uri data ...

  5. android 入门 002 (拨打电话,发送短信)

    一.拨打电话 1.首先做好界面,代码如下: layout =>activity_main.xml 中 <LinearLayout xmlns:android="http://sc ...

  6. Android学习笔记_1_拨打电话

    1.首先需要在AndroidManifest.xml文件中加入拨打电话的权限,对应的配置文件: <?xml version="1.0" encoding="utf- ...

  7. android 中webview调用js

    1.android中利用webview调用网页上的js代码. Android 中可以通过webview来实现和js的交互,在程序中调用js代码,只需要将webview控件的支持js的属性设置为true ...

  8. Android使用Intent实现拨打电话的动作

    使用Intent实现打电话的动作,我们须要在 AnroidMainfest.xml中增加通话权限,打开这个文件,在application节点的前面增加以下内容 <uses-permission ...

  9. Android跳转到拨打电话的页面

    在Android6.0之后,拨打电话需要用户授予动态权限,项目中有此需求,有一种简单的方法,直接携带电话号码跳转到系统拨打电话的页面,很多应用也是这么做的,这样可以减轻工作量 代码如下: Androi ...

随机推荐

  1. APPKIT打造稳定、灵活、高效的运营配置平台

    一.背景 美团App.大众点评App都是重运营的应用.对于App里运营资源.基础配置,需要根据城市.版本.平台.渠道等不同的维度进行运营管理.如何在版本快速迭代过程中,保持运营资源能够被高效.稳定和灵 ...

  2. iOS WKWebview 网页开发适配指南

    iOS WKWebview 网页开发适配指南 微信iOS客户端将于2017年3月1日前逐步升级为WKWebview内核,需要网页开发者提前做好网站的兼容检查和适配.如有问题,可参考文末联系方式,向我们 ...

  3. centOS7.4服务器 yum安装 搭建lamp环境

    // 红色加粗是linux命令 安装gcc和gcc-c++ yum -y install gcc gcc-c++ yum list httpd* 安装apche yum -y install http ...

  4. ArrayList,Vector,LinkedList

    韩梦飞沙  韩亚飞  313134555@qq.com  yue31313  han_meng_fei_sha 数组列表 和 向量Vector, 都是使用数组方式存储. 向量 使用了 同步synchr ...

  5. android 数据存储方式

    韩梦飞沙  韩亚飞  313134555@qq.com  yue31313  han_meng_fei_sha 1,文件 2,内容提供者 3,偏好设置 4,数据库 5,网络存储. 网络存储,就是上传到 ...

  6. Spring的优点

    Spring的优点 1.低侵入式设计,代码污染极低: 2.独立于各种应用服务器,基于Spring框架的应用,可以真正实现Write Once,Run Anywhere的承诺: 3.Spring的DI机 ...

  7. MyBatis之MyBatis环境搭建

    MyBatis之MyBatis环境搭建 一.MyBatis开发环境搭建 1.引入Jar包 ①MyBatis mybatis-3.4.1.jar ant-1.9.6.jar ant-launcher-1 ...

  8. luogu P2439 [SDOI2005]阶梯教室设备利用

    题目链接 luogu P2439 [SDOI2005]阶梯教室设备利用 题解 dp 代码 #include<vector> #include<cstdio> #include& ...

  9. disable_functions php-fpm root

    php.ini disable_functions 禁用某些函数 需要时注意打开 php-fpm 对应conf user group为root时 ERROR: [pool www] please sp ...

  10. java的注解

    本文转载自:http://www.cnblogs.com/mandroid/archive/2011/07/18/2109829.html 一.概念 Annontation是Java5开始引入的新特征 ...