Converted SMS sending to use intent rather than SMSManager

This commit is contained in:
Graham Jones
2018-12-26 20:40:39 +00:00
parent 5793655905
commit 9511b1ee09
5 changed files with 27 additions and 7 deletions

View File

@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="uk.org.openseizuredetector"
android:versionCode="41"
android:versionName="2.5.5">
android:versionCode="42"
android:versionName="2.6">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />

View File

@@ -658,10 +658,19 @@ public class SdServer extends Service implements SdDataReceiver, SdLocationRecei
Time tnow = new Time(Time.getCurrentTimezone());
tnow.setToNow();
String dateStr = tnow.format("%H:%M:%S %d/%m/%Y");
SmsManager sm = SmsManager.getDefault();
// SmsManager sm = SmsManager.getDefault();
for (int i = 0; i < mSMSNumbers.length; i++) {
Log.v(TAG, "sendSMSAlarm() - Sending to " + mSMSNumbers[i]);
sm.sendTextMessage(mSMSNumbers[i], null, mSMSMsgStr + " - " + dateStr, null, null);
// sm.sendTextMessage(mSMSNumbers[i], null, mSMSMsgStr + " - " + dateStr, null, null);
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setDataAndType(Uri.parse("smsto:"), "vnd.android-dir/mms-sms");
intent.putExtra("sms_body", mSMSMsgStr + " - " + dateStr);
intent.putExtra("address", new String(mSMSNumbers[i]));
if (intent.resolveActivity(getPackageManager()) != null) {
startActivity(intent);
} else {
Log.v(TAG, "sendSMSAlarm() - Failed to send SMS.");
}
}
} else {
Log.v(TAG, "sendSMSAlarm() - SMS Alarms Disabled - not doing anything!");