TelephonyUtils
<uses-permission android:name="android.permission.CALL_PHONE"/>
import java.util.ArrayList;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.telephony.SmsManager; public class TelephonyUtils {
/**
* 直接拨打电话
*/
public static void callPhone(Context context, String phoneNum) {
if (phoneNum != null && phoneNum.trim().length() > 0) {
Intent intent = new Intent(Intent.ACTION_CALL);
Uri uri = Uri.parse("tel:" + phoneNum);
intent.setData(uri);
context.startActivity(intent);
}
} /**
* 跳转到拨号界面
*/
public static void CallSysDial(Context context, String phoneNum) {
Intent intent = new Intent(Intent.ACTION_DIAL);
Uri uri = Uri.parse("tel:" + phoneNum);
intent.setData(uri);
context.startActivity(intent);
} /**
* 跳转到系统的短信编辑界面
*/
public static void sendMessage(Context context, String phoneNum, String content) {
Intent intent = new Intent(Intent.ACTION_SENDTO);
Uri uri = Uri.parse("smsto:" + phoneNum);
intent.setData(uri);
intent.putExtra("sms_body", content);
context.startActivity(intent);
} /**
* 直接发送短信,无界面
*/
public static void sendHideMessage(Context context, String phoneNum, String content) {
if (phoneNum != null && phoneNum.trim().length() > 0) {
SmsManager manager = SmsManager.getDefault();
// 消息内容大于70就对消息进行拆分
if (content.length() > 70) {
ArrayList<String> arrayList = manager.divideMessage(content);
for (String message : arrayList) {
manager.sendTextMessage(phoneNum, null, message, null, null);
}
} else {
manager.sendTextMessage(phoneNum, null, content, null, null);
}
}
} }
TelephonyUtils的更多相关文章
随机推荐
- 【1】Git基础
一.Git概念 1.1.Git定义 Git 是一个开源的分布式版本控制系统,用于敏捷高效地处理任何或小或大的项目.Git 是 Linus Torvalds 为了帮助管理 Linux 内核开发而开发 ...
- 2.Bacula Server端安装配置
1. Bacula Server端安装配置 1.1. Bacula Server端安装 1.1.1. 安装bacula依赖包 For Centos6: yum install -y mysql ...
- (一)Android jni打印到logcat
#include <stdio.h> #include <android/log.h> int main(void) { int a = 0x10,b = 0x20; __an ...
- 使用Response下载(支持任何格式)
使用Response下载 下面代码: protected void Button2_Click(object sender, EventArgs e) { Response.ContentType = ...
- bootstrap 表单验证 dem
地址:http://www.jq22.com/yanshi522 一些api详解:http://blog.csdn.net/u013938465/article/details/53507109 ht ...
- C#实现异步阻塞TCP(SocketAsyncEventArgs,SendAsync,ReceiveAsync,AcceptAsync,ConnectAsync)
1.类 (1)socket IO操作内存管理类 BufferManager // This class creates a single large buffer which can be divid ...
- 一个 TCP 连接可以发多少个 HTTP 请求?
曾经有这么一道经典面试题:从 URL 在浏览器被被输入到页面展现的过程中发生了什么?相信大多数准备过的同学都能回答出来,但是如果继续问:收到的 HTML 如果包含几十个图片标签,这些图片是以什么方式. ...
- Linux学习日志(一)
1 .Ubuntu 自带python 2 和 python 3的版本,切换方法如下: shell里执行: sudo update-alternatives --install /usr/bin/pyt ...
- PHP流协议
目前对PHP流协议的定义是数据传输过程中,不同数据类型采用不同处理函数的技术规范(个人理解)这一规范比起传统文件处理函数来的更规范(诸如fget,fwrite,fopen,fclose等) $opts ...
- Codeforces Round #590 (Div. 3) E. Special Permutations
链接: https://codeforces.com/contest/1234/problem/E 题意: Let's define pi(n) as the following permutatio ...