I'm trying to load webservice in to android webview.my request url contain id.what i want to do is take "j" value in for loop and run webpage according to "j" value.when first webpage load,i want to load second web page after 5 seconds.this is my code
final Runnable myRunnable = new Runnable() {
public void run() {
if(i%10==0){
try {
for (int j = 1; j <=3; j++) {
Calendar c = Calendar.getInstance();
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
String Date = df.format(c.getTime());
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
JSONObject json = new JSONObject();
json.put("id", j);
HttpParams httpParams = new BasicHttpParams();
HttpConnectionParams.setConnectionTimeout(httpParams,
TIMEOUT_MILLISEC);
HttpConnectionParams.setSoTimeout(httpParams, TIMEOUT_MILLISEC);
HttpClient client = new DefaultHttpClient(httpParams);
String url = "http://myweb/index?id="+""+j+"";
HttpPost request = new HttpPost(url);
request.setEntity(new ByteArrayEntity(json.toString().getBytes(
"UTF8")));
request.setHeader("json", json.toString());
HttpResponse response = client.execute(request);
HttpEntity entity = response.getEntity();
// If the response does not enclose an entity, there is no need
if (entity != null) {
InputStream instream = entity.getContent();
String result = RestClient.convertStreamToString(instream);
// Log.i("Read from server", result);
JSONObject jsonObj = new JSONObject(result);
String value = jsonObj.getString("posts");
slideWebView.loadUrl(value);// webview process
WebSettings webSettings = slideWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
// myWebView.setInitialScale(100);
slideWebView.getSettings().setLoadWithOverviewMode(true);
slideWebView.getSettings().setUseWideViewPort(true);
}
//
}
} catch (Throwable t5) {
}
}
}
};