摘要:
public void upload(View view) { AsyncHttpClient client = new AsyncHttpClient(); RequestParams requestParams = new RequestParams(); File file = new File("/sdcard/NTUSER.DAT.LOG"); try { requestParams.put("file", file); } catch (FileNotFoundException e) { ... 阅读全文
摘要:
import org.apache.commons.fileupload.FileItem;import org.apache.commons.fileupload.FileUploadException;import org.apache.commons.fileupload.disk.DiskFileItemFactory;import org.apache.commons.fileupload.servlet.ServletFileUpload;import javax.servlet.ServletConfig;import javax.servlet.ServletContext;i 阅读全文
摘要:
使用时无需将这些代码放入子线程去执行,因为其内部已经封装到一个线程中运行了!public void asyncHttpClientGet(View view) { AsyncHttpClient client = new AsyncHttpClient(); client.get( "http://10.0.2.2:8080/LoginServlet?username=张三&password=123", new AsyncHttpResponseHandler() { ... 阅读全文
摘要:
1、将jar包放入Module里的lib文件夹中。(自己创建lib文件夹) 2、在project选中jar包点击右键"Add as library"。 3、此时项目仍然是无法正常编译的,这时需要在项目里的module的build.gradle文件里的dependencies节加入以下内容 compile files('lib/xxxx.jar') 这里files括号里面的地址是相对于build.gradle文件的相对路径4、此时项目正常编译并运行了,但当你的代码中真正创建了引用jar里的类实例时,有可能系统会抛出异常NoClassDefFoundError, 阅读全文
摘要:
final String username = usernameEditText.getText().toString().trim(); final String password = passwrodEditText.getText().toString().trim(); //Android默认模拟器外部的地址为10.0.2.2,而不是localhost和127.0.0.1 final String serverPath = "http://10.0.2.2:8080/LoginServlet"; if (TextUtils.isE... 阅读全文
摘要:
public void httpClientGet(View view) { final String username = usernameEditText.getText().toString().trim(); final String password = passwrodEditText.getText().toString().trim(); //Android默认模拟器外部的地址为10.0.2.2,而不是localhost和127.0.0.1 final String serverPath = "http://10.0.2.... 阅读全文
摘要:
package com.wuyou.submittoserver;import android.os.Bundle;import android.support.v7.app.ActionBarActivity;import android.text.TextUtils;import android.view.View;import android.widget.EditText;import android.widget.Toast;import java.io.BufferedReader;import java.io.ByteArrayOutputStream;import java.i 阅读全文