Created
February 28, 2011 22:59
-
-
Save biznickman/848223 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Processes response from FB API, parses FB Places and transmits place names/IDs to inPulse private class | |
IDRequestListener implements RequestListener { | |
public void onComplete(String response, Object state) { | |
JSONObject json = null; | |
JSONArray jArray = null; | |
try { | |
// process the response here: executed in background thread | |
try { | |
json = Util.parseJson(response); | |
} catch... //Finish this catch statement as needed | |
jArray = json.getJSONArray("data"); | |
Log.d(TAG, "jArray length: " + jArray.length()); | |
for (int i = Math.min(7, jArray.length()); i >= 0; i--) { | |
// Iterate through the array | |
JSONObject eachPlace = jArray.getJSONObject(i); | |
// The outer JSON object | |
Log.d(TAG, "eachPlace: " + i + " " + eachPlace.toString()); | |
ids[i] = eachPlace.getString("id"); | |
Log.d(TAG, "place name: " + ids[i]); | |
int trimmed = Math.min(16, eachPlace.getString("name").length()); | |
places[i] = eachPlace.getString("name").substring(0, trimmed); | |
// The place's name | |
Log.d(TAG, "place name: " + places[i]); | |
// Send each place name + ID to inPulse | |
byte[] send = pulseprotocol.encodeNotification(0, places[i], Integer.toString(i)); | |
mChatService.write(send); | |
} | |
} catch ... //Handle errors as needed | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment