mirror of
https://github.com/cwinfo/envayasms.git
synced 2024-12-04 20:45:32 +00:00
add a poll=true parameter
This commit is contained in:
parent
208945044f
commit
3ed1958ea3
@ -20,7 +20,7 @@
|
||||
android:key="pref_poll_switch"
|
||||
android:title="Server Polling"
|
||||
android:disableDependentsState="false"
|
||||
android:summary="Poll target URL every 15 minutes (Note: Polling increased power consumption, and is not supported by all phone models)"
|
||||
android:summary="Poll target URL every 15 minutes (Note: increases power usage)"
|
||||
></CheckBoxPreference>
|
||||
|
||||
</PreferenceScreen>
|
@ -41,7 +41,7 @@ public class SMSReceiver extends BroadcastReceiver {
|
||||
Log.d("KALSMS", "MSG RCVD:\"" + message + "\" from: " + sender);
|
||||
|
||||
// send the message to the URL
|
||||
String resp = url.openURL(sender, message, targetUrl).toString();
|
||||
String resp = url.openURL(sender, message, targetUrl, false).toString();
|
||||
Log.d("KALSMS", "RESP:\"" + resp);
|
||||
|
||||
// SMS back the response
|
||||
|
@ -26,7 +26,7 @@ public class SMSSender extends BroadcastReceiver {
|
||||
Log.d("KALSMS", "url:\"" + targetUrl);
|
||||
TargetUrlRequest url = new TargetUrlRequest();
|
||||
// send the message to the URL
|
||||
String resp = url.openURL("","",targetUrl).toString();
|
||||
String resp = url.openURL("","",targetUrl, true).toString();
|
||||
|
||||
Log.d("KALSMS", "RESP:\"" + resp);
|
||||
|
||||
|
@ -26,15 +26,19 @@ import android.util.Log;
|
||||
|
||||
public class TargetUrlRequest {
|
||||
|
||||
public String openURL(String sender, String message, String targetUrl) {
|
||||
public String openURL(String sender, String message, String targetUrl, Boolean isPollRequest) {
|
||||
|
||||
String url = targetUrl;
|
||||
List<NameValuePair> qparams = new ArrayList<NameValuePair>();
|
||||
|
||||
if(sender.trim().length() > 0 && message.trim().length() > 0) {
|
||||
List<NameValuePair> qparams = new ArrayList<NameValuePair>();
|
||||
qparams.add(new BasicNameValuePair("sender", sender));
|
||||
qparams.add(new BasicNameValuePair("msg", message));
|
||||
url = targetUrl + "?" + URLEncodedUtils.format(qparams, "UTF-8");
|
||||
}
|
||||
qparams.add(new BasicNameValuePair("msg", message));
|
||||
} else if (isPollRequest) {
|
||||
qparams.add(new BasicNameValuePair("poll", "true"));
|
||||
}
|
||||
|
||||
String url = targetUrl + "?" + URLEncodedUtils.format(qparams, "UTF-8");
|
||||
|
||||
try {
|
||||
HttpClient client = new DefaultHttpClient();
|
||||
HttpGet get = new HttpGet(url);
|
||||
|
Loading…
Reference in New Issue
Block a user