android - 发送短信时一加设备问题
问题描述
One Plus 设备问题在尝试以语法方式获取异常 Java.lang.Security Exception 的发送 SMS 时获取异常。
try {
String message=selectedContactsMap.get(mobileNumber);
/* SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage(mobileNumber,null, message,
null, null);*/
SmsManager sm = SmsManager.getDefault();
ArrayList<String> parts =sm.divideMessage(message);
int numParts = parts.size();
ArrayList<PendingIntent> sentIntents = new ArrayList<PendingIntent>();
ArrayList<PendingIntent> deliveryIntents = new ArrayList<PendingIntent>();
for (int i = 0; i < numParts; i++) {
sentIntents.add(PendingIntent.getBroadcast(context, 0, new Intent(SMS_SENT), 0));
deliveryIntents.add(PendingIntent.getBroadcast(context, 0, new Intent(SMS_DELIVERED), 0));
}
sm.sendMultipartTextMessage(mobileNumber,null, parts, sentIntents, deliveryIntents);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Toast.makeText(Birthday.this,"Send Message Successfully",Toast.LENGTH_SHORT).show();
progressDialog.dismiss();
}
}, 1000);
} catch (Exception e) {
// Toast.makeText(Birthday.this,"Something went
// wrong.",Toast.LENGTH_SHORT).show();
Toast.makeText(Birthday.this,"Error:-
"+e.toString(),Toast.LENGTH_SHORT).show();
e.printStackTrace();`enter code here`
progressDialog.dismiss();
}
所有设备都运行良好唯一的问题是一加设备
解决方案
推荐阅读
- xamarin.forms - 新的 Visual Studio 2019 安装密钥库问题?
- ios - 为什么我的 Web 应用在 iOS(Chrome 和 Safari)上滚动非常慢,但在所有其他平台上都可以?
- javascript - 不能立即更新状态?
- docker - Docker VPN 容器无法 ping
- reactjs - 如何自定义 Material-UI 自动完成的清晰行为?
- c# - 如何删除父节点
使用 C# 在 xml 文件中 - intellij-idea - IntelliJ 和 SVN - 有关更新存储库的信息
- angular7 - 如何在 Angular 7 中进行音频、视频通话和聊天?(开源)
- opencv - Opencv,从深度垫计算像素距离
- sql-server - 临时表和历史表之间的左连接给出了相乘的结果