android打电话程序

Memory01Activity.java

1 package com.tovcd.activity;
2
3 import android.app.Activity;
4 import android.content.Intent;
5 import android.net.Uri;
6 import android.os.Bundle;
7 import android.view.View;
8 import android.widget.Button;
9 import android.widget.EditText;
10
11 public class Memory01Activity extends Activity {
12privateEditTexteditText;
13privateButtonbuttonCall;
14privateStringstrEditText;
15
16@Override
17publicvoidonCreate(BundlesavedInstanceState){
18super.onCreate(savedInstanceState);
19setContentView(R.layout.main);
20editText=(EditText)findViewById(R.id.edit_text_number);
21buttonCall=(Button)findViewById(R.id.button_call);
22
23//while(editText.isFocused()){
24//editText.setText("");
25//
26//}
27
28buttonCall.setOnClickListener(newView.OnClickListener(){
29
30@Override
31publicvoidonClick(Viewv){
32strEditText=editText.getText().toString();
33Intentintent=newIntent(Intent.ACTION_CALL,Uri.parse("tel:"+strEditText));
34Memory01Activity.this.startActivity(intent);
35
36}

37}
);
38
39
40}

41}



AndroidManifest.xml

1 <? xmlversion = " 1.0 " encoding = " utf-8 " ?>
2 < manifestxmlns:android = " http://schemas.android.com/apk/res/android "
3 package = " com.tovcd.activity "
4 android:versionCode = " 1 "
5 android:versionName = " 1.0 " >
6 < applicationandroid:icon = " @drawable/icon " android:label = " @string/app_name " >
7 < activityandroid:name = " .Memory01Activity "
8 android:label = " @string/app_name " >
9 < intent - filter >
10 < actionandroid:name = " android.intent.action.MAIN " />
11 < categoryandroid:name = " android.intent.category.LAUNCHER " />
12 </ intent - filter >
13 </ activity >
14
15 </ application >
16 < uses - sdkandroid:minSdkVersion = " 4 " />
17
18 // 加入打电话权限
19 < uses - permissionandroid:name = " android.permission.CALL_PHONE " />
20 </ manifest >

main.xml
1 <? xmlversion = " 1.0 " encoding = " utf-8 " ?>
2 < LinearLayoutxmlns:android = " http://schemas.android.com/apk/res/android "
3 android:orientation = " vertical "
4 android:layout_width = " fill_parent "
5 android:layout_height = " fill_parent "
6 >
7 < TextView
8 android:layout_width = " fill_parent "
9 android:layout_height = " wrap_content "
10 android:text = " @string/hello "
11 />
12 < EditText
13 android:id = " @+id/edit_text_number "
14 android:layout_width = " fill_parent "
15 android:layout_height = " wrap_content "
16 android:text = " @string/edit_text_number "
17 android:textColor = " #c5c5c5 "
18 />
19 < Button
20 android:id = " @+id/button_call "
21 android:layout_width = " wrap_content "
22 android:layout_height = " wrap_content "
23 android:text = " @string/button_call "
24 />
25 </ LinearLayout >
26

更多相关文章

  1. Android adb.exe程序启动不起来
  2. Android 消息通知栏Notification使用和权限
  3. Android拷贝压缩文件到程序目录
  4. 在应用程序使用android google搜索功能
  5. Android 程序开机自启动
  6. android 再按一次后退键退出应用程序
  7. Android Wear 进阶 2 Creating Wearable Apps-创建手表程序
  8. Android动态权限判断以及动态权限申请
  9. android 在自己的程序中添加Widget

随机推荐

  1. C# Facade外观模式中天河城购物出现的问
  2. C#中异步编程4async与await异步程序开发
  3. .Net中Core使用Socket与树莓派进行通信的
  4. C#中String类型与json之间相互转换的实现
  5. C#中VB.NET给Word文档添加/撤销书签的实
  6. C#编写SqlHelper类的使用详解
  7. 介绍有关C++中继承与多态的基础虚函数类
  8. C# WinForm跨线程访问控件的图文详解
  9. C#中Socket框架的使用教程
  10. C#中关于async与await的使用详解