Android电话拨号器实现方法

Android电话拨号器实现方法,第1张

概述本文实例讲述了Android电话拨号器实现方法。分享给大家供大家参考。具体如下:

本文实例讲述了AndroID电话拨号器实现方法。分享给大家供大家参考。具体如下:

以下案例模拟androID电话拨号器的实现

AndroIDManifest.xml清单列表

<?xml version="1.0" enCoding="utf-8"?><manifest xmlns:androID="http://schemas.androID.com/apk/res/androID"  package="com.ljq.phone"  androID:versionCode="1"  androID:versionname="1.0"> <application androID:icon="@drawable/icon" androID:label="@string/app_name">  <activity androID:name=".MainActivity"     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> <uses-sdk androID:minSdkVersion="7" /> <uses-permission androID:name="androID.permission.CALL_PHONE"/></manifest>

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="请输入电话号码" /> <EditText androID:layout_wIDth="fill_parent"  androID:layout_height="wrap_content"   androID:ID="@+ID/phone" /> <button androID:layout_wIDth="wrap_content"  androID:layout_height="wrap_content"   androID:text="拔打此号码"  androID:ID="@+ID/button" /></linearLayout>

MainActivity类:

package com.ljq.phone;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 MainActivity extends Activity { private EditText phone=null; @OverrIDe public voID onCreate(Bundle savedInstanceState) {  super.onCreate(savedInstanceState);  setContentVIEw(R.layout.main);  phone=(EditText)this.findVIEwByID(R.ID.phone);  button button=(button)this.findVIEwByID(R.ID.button);  button.setonClickListener(new VIEw.OnClickListener(){   public voID onClick(VIEw v) {    String tel=phone.getText().toString();    //方法一, 使用Intent目的: 激活androID组件    //Intent intent=new Intent();    //intent.setAction("androID.intent.action.CALL");    //intent.setData(Uri.parse("tel:"+tel));    //方法二    Intent intent=new Intent("androID.intent.action.CALL",Uri.parse("tel:"+tel));    //方法的内部会自动为intent对象设置类别:androID.intent.category.DEFAulT    startActivity(intent);   }  }); }}

运行结果:

界面初始化:

电话拨打效果:

希望本文所述对大家的AndroID程序设计有所帮助。

总结

以上是内存溢出为你收集整理的Android电话拨号器实现方法全部内容,希望文章能够帮你解决Android电话拨号器实现方法所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://www.54852.com/web/1141758.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-31
下一篇2022-05-31

发表评论

登录后才能评论

评论列表(0条)

    保存