5
0
mirror of https://github.com/cwinfo/envayasms.git synced 2024-09-19 13:59:35 +00:00

add a poll=true parameter

This commit is contained in:
Nir Yariv 2011-01-15 19:27:19 -05:00
parent 208945044f
commit 3ed1958ea3
4 changed files with 13 additions and 9 deletions

View File

@ -20,7 +20,7 @@
android:key="pref_poll_switch" android:key="pref_poll_switch"
android:title="Server Polling" android:title="Server Polling"
android:disableDependentsState="false" 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> ></CheckBoxPreference>
</PreferenceScreen> </PreferenceScreen>

View File

@ -41,7 +41,7 @@ public class SMSReceiver extends BroadcastReceiver {
Log.d("KALSMS", "MSG RCVD:\"" + message + "\" from: " + sender); Log.d("KALSMS", "MSG RCVD:\"" + message + "\" from: " + sender);
// send the message to the URL // 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); Log.d("KALSMS", "RESP:\"" + resp);
// SMS back the response // SMS back the response

View File

@ -26,7 +26,7 @@ public class SMSSender extends BroadcastReceiver {
Log.d("KALSMS", "url:\"" + targetUrl); Log.d("KALSMS", "url:\"" + targetUrl);
TargetUrlRequest url = new TargetUrlRequest(); TargetUrlRequest url = new TargetUrlRequest();
// send the message to the URL // send the message to the URL
String resp = url.openURL("","",targetUrl).toString(); String resp = url.openURL("","",targetUrl, true).toString();
Log.d("KALSMS", "RESP:\"" + resp); Log.d("KALSMS", "RESP:\"" + resp);

View File

@ -26,15 +26,19 @@ import android.util.Log;
public class TargetUrlRequest { 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) { 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("sender", sender));
qparams.add(new BasicNameValuePair("msg", message)); qparams.add(new BasicNameValuePair("msg", message));
url = targetUrl + "?" + URLEncodedUtils.format(qparams, "UTF-8"); } else if (isPollRequest) {
} qparams.add(new BasicNameValuePair("poll", "true"));
}
String url = targetUrl + "?" + URLEncodedUtils.format(qparams, "UTF-8");
try { try {
HttpClient client = new DefaultHttpClient(); HttpClient client = new DefaultHttpClient();
HttpGet get = new HttpGet(url); HttpGet get = new HttpGet(url);