Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.tml.GVBabble;
- import java.io.IOException;
- import java.util.ArrayList;
- import org.apache.http.client.HttpClient;
- import org.json.JSONArray;
- import org.json.JSONException;
- import org.json.JSONObject;
- import com.techventus.server.voice.Voice;
- import android.app.Activity;
- import android.os.Bundle;
- import android.widget.TextView;
- public class GVBabbleActivity extends Activity {
- /** Called when the activity is first created. */
- String userName = <username.;
- String pass = <password>;
- String phoneNumber = <phonenumber>;
- TextView tvDisplay;
- Voice voice;
- HttpClient client;
- JSONObject json;
- JSONArray ja;
- JSONObject jo;
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
- tvDisplay = (TextView)findViewById(R.id.tvDisplay);
- try {
- voice = new Voice(userName, pass);
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- String page = "";
- try {
- page = voice.getInbox();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- page = page.replace("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n", "");
- page = page.replace("<response>\n", "");
- page = page.replace(" <json><![CDATA", "");
- ArrayList<String> listItems = new ArrayList<String>();
- try{
- while (page != "") {
- ja = new JSONArray(page);
- for (int i = 0; i < ja.length(); i++) {
- jo = (JSONObject) ja.get(i);
- listItems.add(jo.getString("displayNumber"));
- }
- }
- } catch (JSONException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- for (int i=0; i<listItems.size(); i++){
- tvDisplay.append(listItems.get(i) + "\n");
- }
- }
- }
Add Comment
Please, Sign In to add comment