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的更多相关文章
随机推荐
- C#读取某一文件夹下的所有文件夹和文件
static List<string> list = new List<string>();//定义list变量,存放获取到的路径 /// <summary> // ...
- STM32写选项字节(option bytes)的正确姿势
STM32 的 Flash information block 部分,包含有特殊的选项字节,可以用于系统配置等信息, 其中还有两个有效字节(实际四个字节,两个是校验字节)的用户自定义数据字节. 在尝试 ...
- 【转】GO语言map类型interface{}转换踩坑小记
原文:https://www.az1314.cn/art/69 ------------------------------------------ mapA := make([string]inte ...
- mpvue打小程序预览码
喂,快给我打一个小程序预览码 前端大全 昨天 (点击上方公众号,可快速关注) 来源:写Bug segmentfault.com/a/1190000015336845 需求 开发小程序的朋友们随时都会听 ...
- django nginx uwsgi 502 Gateway
前提:腾讯云服务器有个内网ip和外网ip 首先检查使用的端口是否正常可用 1.检查端口是否开放,在腾讯云控制台安全组查看 2.检查防火墙端口是否开放 systemctl start firewalld ...
- pandas df 遍历行方法
pandas 遍历有以下三种访法. iterrows():在单独的变量中返回索引和行项目,但显着较慢 itertuples():快于.iterrows(),但将索引与行项目一起返回,ir [0]是索引 ...
- jQuery 查找父节点 parents()与closest()
parents()由内向外,直到最高的父节点停止查找,返回的父节点是多个 closest()由内向外查找,当找到符合规则的一个,则不再查找,返回的是0或1个
- [Javascript] Correctly Type-Checking Numbers
There are two ways to correctly type checks number: console.log(typeof 99.66); // number console.log ...
- [Javascript] How to deal with floating number
What's your expect of the output?: console.log(0.1 + 0.2 === 0.3); The answer is 'false'. Because: 0 ...
- HDU 6088 - Rikka with Rock-paper-scissors | 2017 Multi-University Training Contest 5
思路和任意模数FFT模板都来自 这里 看了一晚上那篇<再探快速傅里叶变换>还是懵得不行,可能水平还没到- - 只能先存个模板了,这题单模数NTT跑了5.9s,没敢写三模数NTT,可能姿势太 ...