我想在获得前一个服务器的响应后向服务器发出请求。
<div class="nav-container">
<ul class="navigation-menu">
<li><a href='start.php'>Home</a></li>
<li><a href='pay.php'>C2B Payments</a> </li>
<li><a href='sms.php'>C2B SMS</a></li>
<li><a href='#'>B2C Payments</a>
<ul>
<li><a href="getbtc.php"> B2C Payments</a></li>
<li><a href="payment.php"> Make Payments</a></li>
</ul>
</li>
<li><a href='bsms.php'>B2C SMS</a></li>
<li><a href='index.php'>Log Out</a></li>
</ul>
</div>
以上从数据库获取图像路径的代码
公共类UploadImagesToServer {
for (int i = 0; i<imgeURLdb.getallImageInformation().size();i++){
ImageUploadBean img = new ImageUploadBean();
img.setImagePath(imgeURLdb.getallImageInformation().get(i).getImagePath());
img.setFlowid(imgeURLdb.getallImageInformation().get(i).getFlowid());
String imagePath = img.getImagePath();
Log.i("imageuploadfile"," image path ----> "+imagePath+" flow id ----> "+imageFlowid);
UploadImagesToServer.postImage(imagePath);
}
} }
以上代码用于发出服务器请求
public static void postImage(String ImageLink){
final HttpClient client = new DefaultHttpClient();
final HttpPost poster = new HttpPost(Constants.MediaUpload);
poster.setHeader("Content-type", "application/json");
MultipartEntity entity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
entity.addPart("file", new FileBody(new File(ImageLink)));
poster.setEntity(entity);
Thread thread = new Thread(new Runnable(){
@Override
public void run(){
try {
client.execute(poster, new PhotoUploadResponseHandler());
} catch (IOException e) {
e.printStackTrace();
}
//code to do the HTTP request
}
});
thread.start();
}
这是从服务器接收响应
答案 0 :(得分:1)
是的,我使用 Android排球同步请求
获得了解决方案diff