功能实现:一个EditView 一个拨打按钮,输入号码跳转到拨号界面

界面布局:activity_call.xml

  //线性垂直布局:一个EditView文本、一个Button按钮
1 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".PhoneActivity" > <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="请输入电话" /> <EditText
android:id="@+id/editText1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="phone" /> <Button
android:id="@+id/callsumbit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="拨打电话" /> </LinearLayout>

CallActivity的Create方法

 protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_call);
Button btn = (Button) findViewById(R.id.callsumbit);
btn.setOnClickListener(new OnClickListener() { @Override
public void onClick(View v) {
EditText etNumber = (EditText) findViewById(R.id.editText1); String number = etNumber.getText().toString();
Intent intent = new Intent();
intent.setAction(Intent.ACTION_CALL);
intent.setData(Uri.parse("tel:" + number));
startActivity(intent);
}
});
}

增加拨打电话的权限:AndroidManifest.xml

 <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ccec.callphone"
android:versionCode="1"
android:versionName="1.0" > <uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<uses-permission android:name="android.permission.CALL_PHONE"/> <application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.ccec.callphone.CallActivity"
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>

至此可以实现拨号功能。

Android 拨号器的简单实现的更多相关文章

  1. Android 拨号器的实现 [视频1]

    Android自带了拨号功能和拨号器 这个是在一个视频里看到的    想写下来记录一下 下面放源代码 /hehe/res/layout/activity_main.xml <RelativeLa ...

  2. 简单拨号器(Android)

    感受: 1.了解了intent中的action和Uri. 2.了解了向下一个活动传递数据. 3.了解了内容提供器. 4.了解自定义适配器. 4.其实T9拨号器和简单计算器原理一样.

  3. Android实现简单拨号器

    Android实现简单拨号器 开发工具:Andorid Studio 1.3 运行环境:Android 4.4 KitKat 代码实现 界面布局只有GridLayout和EditText两个控件,全部 ...

  4. android之电话拨号器

    在android入门的案例中,除了HelloWorld这个经典案例,还有一个电话拨号器需要掌握,现在我就来个电话拨号器的示范,毕竟大牛也是从菜鸟进化而来的. 首先你应该知道自己要设置怎样的UI,然后创 ...

  5. Android实战--电话拨号器

    今天跟着黑马视频建立一个android app--电话拨号器 首先新建一个android项目 activity_main_xml中的代码如下: <RelativeLayout xmlns:and ...

  6. Android学习之电话拨号器

    本人自己是做android驱动的,也会接触到系统层.上层的应用,所以在闲暇的时候也就开始了学习android应用的路程,在这里把这些东西记下来,希望自己能坚持下去,也好以后复习用. 今天先实现一个简单 ...

  7. android开发学习---基础知识学习、如何导入已有项目和开发一个电话拨号器

    一.基础知识点学习  1.Android体系结构 如图所示,android 架构分为三层: (1)最底层是linux内核,主要是各种硬件的驱动,如相机驱动(Camera Driver),闪存驱动(Fl ...

  8. Mono for Android—初体验之“电话拨号器”

    1.Main.axml文件: <?xml version="1.0" encoding="utf-8"?><LinearLayout xmln ...

  9. [Android]电话拨号器开发

    继续今天的Android,经过昨天大体了解了Android开发的一些基本文件结构,今天来做一个电话拨号器! 预期达到的效果 实现过程 首先还是按照昨天第一篇教程,新建一个项目叫PhoneCall的An ...

随机推荐

  1. C#委托 Lamda表达式

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  2. Linux系统的简介及Linux系统的安装

    一.写在前面  本文仅仅对Linux系统进行简要的概述已经对Linux系统的安装进行简要的介绍 二.完成目标 1.Linux操作系统的基本概念 2.Linux系统的安装 三.基本概念 1.什么是操作系 ...

  3. Android 四大组件之Activity生命周期

    写这篇博文之前,已经对android有一定的了解和认识.这篇博文主要讲述android的Activity的生命周期,这是android开发者必须掌握的知识.android的Activity组件拥有7个 ...

  4. RDLC报表系列(二) 行分组

    接上一篇文章的内容,今天来说的是行分组.还是打开demo1.rdlc界面,拖入一个文本框和表 1.在表中随便选择一个字段,不然在添加行组的时候不会自动提示.我这里是选择的Dept 2.在下面的行组中右 ...

  5. c# List<string>和List<int>互相转换

    List<string> 转 List<int> var list = (new[]{"1","2","3"}).T ...

  6. Oracle的分页查询语句优化

    Oracle的分页查询语句基本上可以按照本文给出的格式来进行套用. (一)   分页查询格式: SELECT * FROM  ( SELECT A.*, ROWNUM RN  FROM (SELECT ...

  7. PHP多线程的实现方法详解

    PHP5中可以使用新增的stream_socket_client()函数直接替换掉fsocketopen().PHP5之前的版本,你需要自己动手,用sockets扩展解决问题.PHP5的先进之处在于, ...

  8. mongo设计(三)

    原文:http://blog.mongodb.org/post/88473035333/6-rules-of-thumb-for-mongodb-schema-design-part-3 By Wil ...

  9. 【转】vs2010下创建webservice

    题记:学了六个月java一直想做java,没想到进了.NET项目组,还是VB2012,还有WebService,压力山大,这篇纯粹看看多图的效果,版主不要怪罪. Visual Studio 2010默 ...

  10. ERS卫星

    http://www.esa.int/Our_Activities/Operations/ERS-2 ERS-2 ROLE Earth observation (EO) LAUNCH DATE 21 ...