5
0
mirror of https://github.com/cwinfo/envayasms.git synced 2024-11-09 10:20:25 +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: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>

View File

@ -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

View File

@ -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);

View File

@ -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;
if(sender.trim().length() > 0 && message.trim().length() > 0) {
List<NameValuePair> qparams = new ArrayList<NameValuePair>();
if(sender.trim().length() > 0 && message.trim().length() > 0) {
qparams.add(new BasicNameValuePair("sender", sender));
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 {
HttpClient client = new DefaultHttpClient();
HttpGet get = new HttpGet(url);