android项目1:打电话
android项目1:打电话
一、效果图


二、步骤
1、画好主界面
/call/res/layout/activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" > <EditText
android:id="@+id/editText_phoneNumber"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.00"
android:ems="10" > <requestFocus />
</EditText> <Button
android:id="@+id/btn_call"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_weight="0.00"
android:text="@string/btn_call" /> </LinearLayout>
2、编好代码
com.fry.call_1.MainActivity
package com.fry.call_1; import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText; public class MainActivity extends Activity{
private Button btn_call;//创建一个button对象
private EditText editText_phoneNumber;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);//父类操作
setContentView(R.layout.activity_main);//引入名为activity_main的界面
btn_call=(Button) findViewById(R.id.btn_call);//找id为btn_openActivity的button
editText_phoneNumber=(EditText) findViewById(R.id.editText_phoneNumber); //1、给按钮设置点击事件
btn_call.setOnClickListener(new OnClickListener() {//设置button点击监听 @Override
public void onClick(View v) {//onclick事件
// TODO Auto-generated method stub
//2、拿到编辑框中的号码
String phoneNumber=editText_phoneNumber.getText().toString();
//3、给这个号码打电话 Intent intent=new Intent();//初始化intent
38 intent.setAction("android.intent.action.CALL");
39 intent.addCategory("android.intent.category.DEFAULT");
40 intent.setData(Uri.parse("tel:"+phoneNumber));
startActivity(intent);//打开activity
}
});
}
}
3、设置好权限
/call/AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.fry.call_1"
android:versionCode="1"
android:versionName="1.0" > <uses-permission android:name="android.permission.CALL_PHONE" /> <uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="19" /> <application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.fry.call_1.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>
<activity android:name="com.fry.call_1.Activity01" android:exported="true"></activity>
</application> </manifest>
android项目1:打电话的更多相关文章
- Android项目结构 以及体系结构
学习Android平台的人一般对Android的平台的应该有点认识 其它的就不多讲了 Android项目一般由以下几个部分构成 以上是一个简单的Android项目结构目录图 1. src 主要是 源 ...
- Android项目的目录结构 初学者记录
Android项目的目录结构 Activity:应用被打开时显示的界面 src:项目代码 R.java:项目中所有资源文件的资源id Android.jar:Android的jar包,导入此包方可使用 ...
- Android——eclipse下运行android项目报错 Conversion to Dalvik format failed with error 1解决
在eclipse中导入android项目,项目正常没有任何错误,但是运行时候会报错,(clean什么的都没用了.....)如图: 百度大神大多说是jdk的问题,解决: 右键项目-Properties如 ...
- eclipse — 导入android项目后识别成java项目的问题及解决
最近在eclipse导入android项目的时候遇到了奇葩问题,再此记录 遇到的问题就是:将完好的android项目导入到eclipse的时候,原本这是一个很容易的事情,但是导入成功后发现,,,靠ec ...
- 用Kotlin创建第一个Android项目(KAD 01)
原文标题:Create your first Android project using Kotlin (KAD 01) 作者:Antonio Leiva 时间:Nov 21, 2016 原文链接:h ...
- Android之什么是Activity和常用的ADB命令以及Android项目结构的认识
总结一下之前学习Android的一些内容 一: Android常用的ADB命令(adb android调试桥) 1.adb devices 查看模拟器设备并重新连接. 2.adb ki ...
- eclipse将android项目生成apk并且给apk签名
转载:http://www.cnblogs.com/tianguook/archive/2012/09/27/2705724.html 生成apk最懒惰的方法是:只要你运行过android项目,到工作 ...
- Android开发学习——Android项目的目录结构
Android项目的目录结构: 资源文件夹: 清单配置文件: Android的四大组件在使用前全部需要在清单文件中配置 <?xml version="1.0" encodin ...
- Android项目实战(二十五):Android studio 混淆+打包+验证是否成功
前言: 单挑Android项目,最近即时通讯用到环信,集成sdk的时候 官方有一句 在 ProGuard 文件中加入以下 keep. -keep class com.hyphenate.** {*;} ...
随机推荐
- 【开发者笔记】解析具有合并单元格的Excel
最近公司让做各种数据表格的导入导出,就涉及到电子表格的解析,做了这么多天总结一下心得. 工具:NOPI 语言:C# 目的:因为涉及到导入到数据库,具有合并单元格的多行必然要拆分,而NPOI自动解析的时 ...
- nanomsg(ZeroMQ with C)
1.应用手册 https://github.com/nanomsg/nanomsg % mkdir build % cd build % cmake .. % cmake --build . % ct ...
- Java栈之链式栈存储结构实现
一.链栈 采用单链表来保存栈中所有元素,这种链式结构的栈称为链栈. 二.栈的链式存储结构实现 package com.ietree.basic.datastructure.stack; /** * 链 ...
- appium ios 自动化测试
iOS自动化测试:Appium 从入门到实践https://www.jianshu.com/p/43f858180557appium自动化测试iOS Demohttps://www.jianshu.c ...
- python16_day20【Django_继续抽屉项目】
一.djangoAdmin和表结构 1.项目名称 python manage startapp web # 前端页面 python manage startapp repository # 只是数 ...
- JQuery变量数字相加的研究
在 jquery中,一个变量和一个数字相加,期望得到1+2=3但是: eg: <input type="text" class="input_Num" i ...
- React:快速上手(7)——使用中间件实现异步操作
React:快速上手(7)——使用中间件实现异步操作 本文参考链接:Stack Overflow redux-thunk 我们使用store.dispath进行派发时,只能传递一个普通对象进去,如下: ...
- iClap助力移动互联网企业高效实现规范化管理
移动互联网的迅速崛起,智能移动客户端深刻而全面地影响着人类生活与工作习惯.而企业办公已从原始的纸张办公,到固定PC办公,跨入到一个应用范围更广.效率更高的移动办公时代.由静生动,让企业办公更加人性化和 ...
- Connecting to a Remote Serial Port over TCP/IP
https://www.acmesystems.it/socat This article illustrates how to realize a lan to serial gateway Rem ...
- SparkStreaming程序设计
一个简单的 Streamin wordCount object StreamingWordCount { def main(args: Array[String]): Unit = { val spa ...