i just creating an android ap. so in that i created a connection with http to servlet. but i want that request is pass automatic after few seconds. so help me to find solution.
this is my connector class
public String Intraday() {
String url = URL+"?flag="+"intra";
httpPost = new HttpPost(url);
try{
HttpResponse httpResponse = httpclient.execute(httpPost);
int statuscode = httpResponse.getStatusLine().getStatusCode();
if(statuscode == 200){
String responceMsg = getResponse(httpResponse);
return responceMsg;
}else{
return null;
}
}catch(ClientProtocolException e){
Log.e(TAG, e.getMessage(),e);
}catch (IOException e) {
Log.e(TAG, e.getMessage(),e);
}
return null;
}
this is the class from i calling my connector class now tell me where i put the code of thread??
try
{
String str = Connector.getInstance().Intraday(); //now tell me where i write
String st = new String(str);
Log.e("Main",st);
String[] rows = st.split("_");
TableLayout tableLayout = (TableLayout)findViewById(R.id.tab);
tableLayout.removeAllViews();
for(int i=0;i<rows.length;i++){
String row = rows[i];
TableRow tableRow = new TableRow(getApplicationContext());
final String[] cols = row.split(";");
IntraThread popup = null;
Handler handler = null;
for (int j = 0; j < cols.length; j++) {
final String col = cols[j];
final TextView columsView = new TextView(getApplicationContext());
columsView.setText(String.format("%7s", col));
tableRow.addView(columsView);
if(j==0)
{
head= col;
}
if(j==2)
{
price = Integer.parseInt(col);
}
if(j==4)
{
target = Integer.parseInt(col);
}
if(j==5)
{
handler = new Handler();
ltp = Integer.parseInt(col);
popup = new IntraThread(handler,head, target,ltp,price,Intraday.this,columsView);
}
if(j==6){
popup.setColumnViewexit(columsView);
handler.postDelayed(popup, 300);
}
}
tableLayout.addView(tableRow);
}
}
catch(Exception e)
{
Log.e("Main",e.toString());
}
Here is short of dummy code modify it to suit your needs
Replace the first line in Try
String str = Connector.getInstance().Intraday(); //now tell me where i writewith the code above provided