Android简单拨号
package com.example.phonecall; import android.net.Uri;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast; public class MainActivity extends Activity { @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); Button btn=(Button)findViewById(R.id.Call);
btn.setOnClickListener(new OnClickListener() { @Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
makeCall();
} private void makeCall() {
// TODO Auto-generated method stub
Log.i("Make call", ""); Intent phoneIntent = new Intent(Intent.ACTION_CALL);
phoneIntent.setData(Uri.parse("tel:10086")); try {
startActivity(phoneIntent);
finish();
Log.i("Finished making a call...", "");
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(MainActivity.this,
"Call faild, please try again later.", Toast.LENGTH_SHORT).show();
} }
});
} @Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
} }
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" > <Button android:id="@+id/Call"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/make_call"/> </LinearLayout>
Strings.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources> <string name="app_name">Phonecall</string>
<string name="action_settings">Settings</string>
<string name="hello_world">Hello world!</string>
<string name="make_call">Call </string> </resources>
AndroidManifest.xml中写入权限:
<uses-permission android:name="android.permission.CALL_PHONE"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
run:
Android简单拨号的更多相关文章
- Android实现简单拨号器
Android实现简单拨号器 开发工具:Andorid Studio 1.3 运行环境:Android 4.4 KitKat 代码实现 界面布局只有GridLayout和EditText两个控件,全部 ...
- Android之拨号界面图片风格,无信息默认显示界面修改
Android之拨号界面图片风格,无信息默认显示界面修改 点开Dialer app,出现拨号,联系人,收藏三个选项卡,也就是三个Fragment,在三个界面都没有信息的时候会显示一个时钟,联系人,收藏 ...
- Android简单逐帧动画Frame的实现(二)
Android简单逐帧动画Frame的实现 Android简单逐帧动画Frame的实现 1.逐帧动画 即是通过播放预先排序好的图片来实现动态的画面,感觉像是放电影. 2.实现步骤: 1. 在工程里 ...
- Android简单文件浏览器源代码 (转)
Android简单文件浏览器源代码 (转) activity_main .xml <LinearLayout xmlns:android="http://schemas.android ...
- 简单拨号器(Android)
感受: 1.了解了intent中的action和Uri. 2.了解了向下一个活动传递数据. 3.了解了内容提供器. 4.了解自定义适配器. 4.其实T9拨号器和简单计算器原理一样.
- Android入门之简单拨号器
效果图: package jk.phone; import android.net.Uri; import android.os.Bundle; import android.app.Activity ...
- Android简单介绍SharedPreference,内部文件,sdcard数据存储
SharedPreference 以xml的结构储存简单的数据,储存在data/data/程序包名/shared_prefs文件夹中 使用方式 创建对象的方式有三种 Context 的 getShar ...
- [Android]电话拨号器开发
继续今天的Android,经过昨天大体了解了Android开发的一些基本文件结构,今天来做一个电话拨号器! 预期达到的效果 实现过程 首先还是按照昨天第一篇教程,新建一个项目叫PhoneCall的An ...
- android简单登陆和注册功能实现+SQLite数据库学习
最近初学android,做了实验室老师给的基本任务,就是简单的登陆和注册,并能通过SQLite实现登陆,SQlLite是嵌入在安卓设备中的 好了下面是主要代码: 数据库的建立: 这里我只是建立了一个用 ...
随机推荐
- WinDbg x 64 使用 SOS: 无法找到运行时 DLL (clr.dll)
http://www.datazx.cn/Forums/en-US/59aa78c9-dc05-43c8-9efe-e7b132056afc/action?threadDisplayName=win ...
- git乱码问题
直接看连接吧. http://my.oschina.net/lujian863/blog/168837
- Mysqlbinlog使用
Mysqlbinlog使用 1.binlog日志打开方法 在my.cnf这个文件中加一行(Windows为my.ini).#vi /etc/my.cnf[mysqld]log-bin=mysqlb ...
- 基于RealSense的坐姿检测技术
计算机的飞速普及,让人们将越来越多的工作放在计算机上去完成,各行各业,尤其是程序开发人员.文字工作者,在计算机上的工作时间越来越长,这种情况下不良的坐姿对颈肩腰椎都会产生很大影响,容易导致多种疾病的发 ...
- .NET下的延迟加载
在应用中有很多实例可能需要延迟创建对象, 比如设计模式中的单例模式就是一种非常常见的情况.如果不考虑线程安全我们通常会编写如下代码: public class SingleInstance { pri ...
- 使用Unity制作游戏关卡的教程(二)
转自:http://gamerboom.com/archives/75554 作者:by Matthias Zarzecki 本文是“使用Unity制作<The Fork Of Truth> ...
- contiki-main.c 中的process系列函数学习笔记 <contiki学习笔记之六>
说明:本文依然依赖于 contiki/platform/native/contiki-main.c 文件. ---------------------------------------------- ...
- SPOJ LIS2 Another Longest Increasing Subsequence Problem 三维偏序最长链 CDQ分治
Another Longest Increasing Subsequence Problem Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://a ...
- Codeforces Round #326 (Div. 2) C. Duff and Weight Lifting 水题
C. Duff and Weight Lifting Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest ...
- string和stringbuilder的解剖
String和StringBuilder的深入解析 前言:本文出发点是我们开发的过程中是否真正的理解stringbuilder的使用,string字符串操作的是如何实现(哈希表),stringbu ...