- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我使用了 SmsManager.getDefault().sendTextMessage 但没有发送短信我想以编程方式发送短信请看这段代码
编辑代码:
public void sendEmail(View view){
if (hasConnection() == false){
Intent goPop = new Intent(getApplicationContext(),ShowPopup.class);
startActivity(goPop);
finish();
}
statusOfGPS = mLocationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
// Set Email option
final Intent i = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto",OpsEmail, null));
//Check Send SMS
if (mSMSCheckbox.isChecked()){
SMS = true;
}else{
SMS = false;
}
//Check GPs
if (statusOfGPS == true){
LocationBy = "GPS";
}else{
LocationBy = "INTERNET";
}
setUpAddress();
//SMS true
if (mLocationClient != null && mLocationClient.isConnected() && SMS == true) {
//set massage to send
DescribeText = "This is a Emergency message \n\n PLEASE HELP ME!!! at\n\n "+
addressText+ "\n Location("+LocationBy+"):("+mLocationClient.getLastLocation().getLatitude() + mLocationClient.getLastLocation().getLongitude()+
") \n\n Please check maps <a href='https://maps.google.com/maps?q="+mLocationClient.getLastLocation().getLatitude()+","+mLocationClient.getLastLocation().getLongitude()+"&ll="+mLocationClient.getLastLocation().getLatitude()+","+mLocationClient.getLastLocation().getLongitude()+"&z=17'>here</a>";
//send SMS First
String sent = "android.telephony.SmsManager.STATUS_ON_ICC_SENT";
SmsManager smsManager = SmsManager.getDefault();
PendingIntent pi = PendingIntent.getBroadcast(this, 0, new Intent(sent), 0);
smsManager.sendTextMessage(OpsPhoneNumber, null, DescribeText, pi,null);
//send email
i.putExtra(Intent.EXTRA_SUBJECT, "Emergency Location");
i.putExtra(Intent.EXTRA_TEXT,Html.fromHtml(DescribeText));
try {
startActivity(Intent.createChooser(i, "Send mail..."));
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(getApplicationContext(), "There are no email clients installed.", Toast.LENGTH_LONG).show();
}
Log.d(TAG, "gps =" + statusOfGPS);
}
}
下一行//先发送短信
我用
SmsManager.getDefault().sendTextMessage(OpsPhoneNumber, null, DescribeText, null,null);
在我的 list 文件中我有:
<uses-permission android:name="android.permission.SEND_SMS"/>
我要测试的设备是 android 4.2.2 和 4.1.1但是应用程序不发送短信如何解决这个问题?
最佳答案
SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage("", null, "< message body>", null, null);
SmsManager 在您的 android mainfest 中需要 SMS_SEND 权限。
关于android - (Android) 为什么我使用 SmsManager.getDefault().sendTextMessage 但应用程序不发送短信?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18139514/
早上好,感谢并抱歉我的英语! 我正在开发一个 Android 应用程序,我希望该应用程序使用 SmsManager 发送大量短信。这很好,但是当我尝试在每条短信的发送之间实现任何类型时,问题就出现了。
我正在开发一个自动回复 Android 应用程序,如果传入的号码与所选号码(即保存在数据库中)匹配,它将向传入号码发送消息。它运行成功,但有时会发送两次消息,它会向该传入号码发送三条消息。 我正在使用
我正在使用以下代码发送短信。但这似乎不会在未发送短信时产生异常。例如,当没有足够的钱发送时,我仍然会去 smsSucces();有没有人知道解决此问题的方法以确保它已发送? private b
我正在尝试使用 smsManager 从 BroadCast Receiver 发送文本消息。我收到此错误消息 NullPointerException。我不知道这有什么问题。我厌倦了这个错误。这是我
我正在尝试发送多条 SMS 消息。我的代码: for (Entry entry : book.entrySet()) { sendSMS(entry.getValue(), message);
我正在开发一些发送短信的应用程序。我的问题是,当我尝试发送长文本时,它不会发送消息。我知道有字符数限制。 我正在使用 SmsManager: SmsManager SMS = SmsManager.g
例如,当消息中有重音时,我的 Android 短信应用程序会出现一些奇怪的行为; smsTEXT = “如果您愿意,请尽快调用办公室。” 消息在单个 160 个字符的短信长度内,但是当我调用它时; A
我在尝试发送多部分 SMS 消息时收到来自三星设备的崩溃日志,这是导致崩溃的行: SmsManager.getDefault().sendMultipartTextMessage(phone, nul
当我使用 SmsManager 发送 SMS 时,广播的结果 Intent 的值为 5 Activity.RESULT_OK SmsManager.RESULT_ERROR_GENERIC_FAILU
我已经把这个文件包含在android 2.3.3的项目中 import android.telephony.gsm.SmsManager; 显示代码如下(删除smsmanager文本) import
我正在尝试使用 android.telephony.SMSManager 发送短信。当我向全国各地的人发送短信时,它有效。例如,当我尝试向加利福尼亚发送 SMS 时,它不再起作用。 此外,当我尝试向加
这个问题不太可能对任何 future 的访客有帮助;它只与一个较小的地理区域、一个特定的时间点或一个非常狭窄的情况相关,通常不适用于全世界的互联网受众。如需帮助使此问题更广泛适用,visit the
我对我正在创建的短信应用程序有疑问(学习目的)。 发送短信时,我希望在发送(或未发送)后显示一条 toast 消息 问题是,一旦我点击发送,我想关闭 Activity ,但仍然会出现 toast 消息
我想了解 import android.telephony.SmsManager; 如何知道短信已成功发送。 我正在使用学习指南中的这段代码 protected void sendSMSMessag
我正在使用 VS 2015,并从我的 nexus 4 设备进行调试。为什么此行抛出异常(与任何电话号码相同的结果 - 包括实数)? (未显示详细信息)。 SmsManager.Default.Send
我正在尝试制作一个可以发送彩信的应用程序,无需使用 native Android 消息传递应用程序。我按照示例 here .我的日志语句似乎可以正确打印,但我不明白为什么没有发送彩信。 另外,我对示例
我正在构建一个应用程序来发送短信和接收送达报告。我在表单上有一个按钮,其 onclick 属性为 m1,当我单击该按钮时,应用程序崩溃了。我做错了什么? 这是代码: public class m1g
我正在尝试在 Android 2.2 中创建一个应用程序,该应用程序使用 android.telephony.SmsManager 在后台自动向 6 个不同的联系人发送相同的消息作为 Service同
package com.soft.mash.contactmanager; import android.app.Activity; import android.os.Bundle; import
我尝试在 android 中使用 SmsManager 发送 Text Message。消息传递正常。当我尝试用不同的语言发送消息时,它以 ??????? 形式发送。我不知道有什么问题。 try {
我是一名优秀的程序员,十分优秀!