android 开发电话拔号
来源:互联网 发布:西南证券炒股软件 编辑:程序博客网 时间:2024/05/16 18:52
第一步新建一个名为phone的android项目
第二步画用户页面,我们需要一个TextVIew EditVIew Button 这三个组件,部局现在使用线性部局(linerLayout)具体内容如下。
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/phone" /> <EditText android:id="@+id/phone" android:layout_width="fill_parent" android:layout_height="wrap_content" /> <Button android:id="@+id/button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/button" /></LinearLayout>
第三步:需要在页面展示的提示内容,我在values文件夹下新建了一个me.xml文件,格式如下:
me.xml<?xml version="1.0" encoding="utf-8"?><resources> <string name="phone">请输入号码</string> <string name="button">播号</string></resources>
内容会在R.java 文件下自动生成对应的引用。
第四步:把需要的logo 文件放到drawable-hdpi下,注:有时候直接放入会出错,如果出错,请用mspaint 打开再保存成png 格式放入。
第五步:也是最重要的一步开始编码,实现我们需求的拔号功能, 但不是我们全部开发,是调用android已实现的拔号功能。
package com.hkrt.action;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 PhoneActivity extends Activity {/** Called when the activity is first created. */private EditText phone;//获取电话号码 @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); phone = (EditText) findViewById(R.id.phone); Button bu = (Button)findViewById(R.id.button); bu.setOnClickListener(new buttonListener()); } public final class buttonListener implements View.OnClickListener{// Intent.ACTION_DIAL@Overridepublic void onClick(View v) {String phoneNum= phone.getText().toString();Intent intent = new Intent("android.intent.action.CALL", Uri.parse("tel://" + phoneNum));startActivity(intent);} }}
第六步:给用户添加拔号权限;在AndroidMainifest.xml中添加。
<uses-permission android:name="android.permission.CALL_PHONE"/>
同时把我们需要的小图标Logo加上去,
android:icon="@drawable/zs"
最终项目图:
最后的页面:
两个不同的拔号结果:
两个参数的不同,出来的结果名异。
- android 开发电话拔号
- android电话拔打
- 电话拔号程序
- Android手机拔号程序
- android电话开发
- Android:BroadcastReceiver:采用广播接收者拦截外拔电话、发送广播、其他常用广播、特性
- Android调用系统拔号和短信
- android手机电话应用开发
- Android(开发):拨打电话
- Android App开发--电话拦截
- Android开发笔记--电话拔号器
- Android开发_电话拨号
- android开发 - 电话拨号器
- android学习笔记---38_采用广播接收者拦截外拔电话,实现原理以及实例源码
- 关于Delphi开发用“猫”拔号的程序
- 多种模块拔号上网驱动开发调试
- Android开发(一)拨打电话程序
- Android开发4:电话拨号器
- PSIA与ONVIF:如何评估两种视频监控标准
- 添加成功关闭层
- java.util.List
- GNUstep开发工具ProjectCenter0.6.0安装
- Android移植到VirtualBox及详细流程
- android 开发电话拔号
- [置顶]MessageDigest的功能及用法
- Android Market api
- 进程间通讯
- 如何判断一个文件是否存在
- http头的技术资料
- winform简单截图
- Python随笔之星号在字符串上的应用
- DMA基础(ARM学习2)