how to use timer.schedule() for ping the server from given url or use some other technique
<p>I have an url for getting raw data from server. After getting data I use JSON parsing for displaying data in list view. How to hit the url in every 10 minutes for getting new responses? And refreshing list. I am new in android and I will be greatly oblige of you. Thanks in advance.</p>

<pre><code>public class output extends ListActivity{
    private ProgressDialog m_ProgressDialog = null; 
    private ArrayList&lt;Order&gt; m_orders = null;
    private OrderAdapter m_adapter;
    private Runnable viewOrders;
    public static String cabname;
    public static String  cabbookingid;
    public static String price;
    public static String cabrating;

    public static final String PREFS_NAME = "Settings1";
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.listonruntime);                  

        HttpClient client = new DefaultHttpClient();
        try {                                                 

         URL url = new URL("http://qrrency.com/mobile/j2me/cab/CabBookingStatus.php?requestid=666");

            BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
            int l=0;
            int k=0;
            StringBuffer buffer=new StringBuffer();
            String str="";
            while ((l=in.read())!=-1) {
                    buffer.append((char)l);
                    str=str+(char)l;

            } 

           in.close();              

            try {
                JSONObject json = new JSONObject(str);
                JSONArray nameArray=json.getJSONArray("bookings");
                JSONObject[] cabListing=new JSONObject[nameArray.length()];
                for (int i = 0; i &lt; cabListing.length; i++) {

                    //JSONObject jSONObject = cabListing[i];
                     JSONObject jSONObject = nameArray.getJSONObject(i);
                     JSONObject temp=jSONObject.getJSONObject("booking");
                     cabbookingid=temp.getString("cabbookingid");
                     cabname=temp.getString("CabDriverName");
                     price=temp.getString("price");
                     cabrating= temp.getString("cabrating");



                     setResult(RESULT_OK);

            }

            } catch (JSONException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

        } catch (MalformedURLException e)
        {
        } catch (IOException e) 
        {

    }

        m_orders = new ArrayList&lt;Order&gt;();
        this.m_adapter = new OrderAdapter(this, R.layout.row1, m_orders);
        setListAdapter(this.m_adapter);
        viewOrders = new Runnable(){

            @Override
            public void run() {
                getOrders();
            }
                  };
        Thread thread =  new Thread(null, viewOrders);
        thread.start();
        m_ProgressDialog = ProgressDialog.show(output.this,    
              "Please wait...", "Retrieving data ...", true);
    }

    private Runnable returnRes = new Runnable() {


        @Override
        public void run() {

            if(m_orders != null &amp;&amp; m_orders.size() &gt; 0)
            {
                m_adapter.notifyDataSetChanged();
                for(int i=0;i&lt;m_orders.size();i++)
                m_adapter.add(m_orders.get(i));
            }
            m_ProgressDialog.dismiss();
            m_adapter.notifyDataSetChanged();

        }

    };


    private void getOrders(){
          try{

              m_orders = new ArrayList&lt;Order&gt;();
              Order o1 = new Order();
              o1.setOrderName(cabname);
              o1.setOrderStatus(cabbookingid);
              o1.setfrom(price);
              o1.setfrom1(cabrating);
              m_orders.add(o1);
              Thread.sleep(5000);
              Log.i("ARRAY", ""+ m_orders.size());
            } catch (Exception e) { 
              Log.e("BACKGROUND_PROC", e.getMessage());
            }
            runOnUiThread(returnRes);
        }
    private class OrderAdapter extends ArrayAdapter&lt;Order&gt; {

        private ArrayList&lt;Order&gt; items;

        public OrderAdapter(Context context, int textViewResourceId, ArrayList&lt;Order&gt; items) {
                super(context, textViewResourceId, items);
                this.items = items;
        }
        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
                View v = convertView;
                if (v == null) {
                    LayoutInflater vi = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                    v = vi.inflate(R.layout.row1, null);
                }
                Order o = items.get(position);
                if (o != null) {

                        TextView tt = (TextView) v.findViewById(R.id.toptext);
                        TextView mt = (TextView) v.findViewById(R.id.middletext);
                        TextView bt = (TextView) v.findViewById(R.id.bottomtext1);
                        TextView bt2 = (TextView) v.findViewById(R.id.bottomtext2);

                        if (tt != null) {
                              tt.setText("Name: "+o.getOrderName());   
                        }

                        if(mt != null){
                              mt.setText("Cab Booking Id: "+ o.getOrderStatus());
                        }
                        if(bt != null){
                            bt.setText("Price: "+ o.getfrom());
                      }

                        if(bt2 != null){
                            bt2.setText("cab rating: "+ o.getfrom1());
                      }

                }
                return v;
        }
}
}
</code></pre>
