Permalink
Browse files

-Fixed error in passing params

  • Loading branch information...
akshaydashrath committed Dec 11, 2011
1 parent ad9e46f commit f7074db0ec29278cbabcadfca68c53ae92c43fb7
@@ -12,6 +12,8 @@
public class TestActivity extends Activity {
+ //private static final String URL = "https://api.twitter.com/1/statuses/public_timeline.json?count=3&include_entities=true";
+
private ResultReceiver resultreceiver = new ResultReceiver(null) {
@Override
protected void onReceiveResult(int resultCode, Bundle resultData) {
@@ -24,8 +26,8 @@ protected void onReceiveResult(int resultCode, Bundle resultData) {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
- Uri uri = Uri.parse("https://api.twitter.com/1/statuses/public_timeline.json?count=3&include_entities=true");
- Intent intent = new IntentBuilder(this).setData(uri).setHttpType(SyncService.SERVICE_TYPE_GET).setResultReceiver(resultreceiver).build();
+ Uri uri = Uri.parse("https://api.twitter.com/1/statuses/public_timeline.json");
+ Intent intent = new IntentBuilder(this).setData(uri).setHttpType(SyncService.SERVICE_TYPE_GET).withParam("count", "3").withParam("include_entities", "true").setResultReceiver(resultreceiver).build();
startService(intent);
}
}
@@ -39,7 +39,7 @@ public IntentBuilder withParam(String key, String value){
} else {
extra = extra + "&" + key + "=" + URLEncoder.encode(value,"UTF-8");
}
- intent.putExtra(SYNC_INTENT_EXTRA_PARAM, value);
+ intent.putExtra(SYNC_INTENT_EXTRA_PARAM, extra);
} catch (Exception e){
e.printStackTrace();
}
@@ -17,6 +17,7 @@
import android.os.Build;
import android.os.Bundle;
import android.os.ResultReceiver;
+import android.util.Log;
public class SyncService extends IntentService {
@@ -46,6 +47,9 @@ public void onCreate() {
}
private Bundle doGetServiceCall(Uri uri, Bundle bundle, Intent intent) throws IOException {
+ String param = intent.getStringExtra(IntentBuilder.SYNC_INTENT_EXTRA_PARAM);
+ uri = uri.buildUpon().appendEncodedPath(param).build();
+ Log.i("XXX", "Url = " + uri);
URL url = new URL(uri.toString());
HttpURLConnection urlConnection = getHttpUrlConnection(url);
urlConnection.setRequestMethod(HTTP_GET);

0 comments on commit f7074db

Please sign in to comment.