本文整理汇总了Java中com.lidroid.xutils.http.client.multipart.MultipartEntity类的典型用法代码示例。如果您正苦于以下问题:Java MultipartEntity类的具体用法?Java MultipartEntity怎么用?Java MultipartEntity使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MultipartEntity类属于com.lidroid.xutils.http.client.multipart包,在下文中一共展示了MultipartEntity类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: SignUp
import com.lidroid.xutils.http.client.multipart.MultipartEntity; //导入依赖的package包/类
/**注册方法。
* @param phoNum
* @param pwd
* @param SMSCode 短信验证码
* @param call 注册回调接口,字符串包含error证明错误
*/
public static void SignUp(String phoNum,String pwd,String SMSCode,CallString call){
String url = APIUtils.SignUpUrl;
MultipartEntity reqEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
try {
reqEntity.addPart("password", new StringBody(pwd));
reqEntity.addPart("device_id", new StringBody("864690025974851"));
reqEntity.addPart("client_id", new StringBody("1089857302"));
reqEntity.addPart("phone", new StringBody(phoNum));
reqEntity.addPart("client_secret",new StringBody("38e8c5aet76d5c012e32"));
reqEntity.addPart("verify_code",new StringBody(SMSCode));
reqEntity.addPart("grant_type",new StringBody("phone"));
} catch (Exception e) {
e.printStackTrace();
}
POST2meiPai(reqEntity,url,call);
}
示例2: Login
import com.lidroid.xutils.http.client.multipart.MultipartEntity; //导入依赖的package包/类
/**登录方法 返回结果调用JsonPaser解析
* @param phoNum
* @param pwd
* @param call 登录信息回调接口 登录成功返回包含access_token和一个User对象的JSON
*/
public static void Login(String phoNum,String pwd,CallString call){
String url = APIUtils.LoginUrl;
MultipartEntity reqEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
try {
reqEntity.addPart("password", new StringBody(pwd));
reqEntity.addPart("device_id", new StringBody("864690025974851"));
reqEntity.addPart("client_id", new StringBody("1089857302"));
reqEntity.addPart("phone", new StringBody(phoNum));
reqEntity.addPart("client_secret",new StringBody("38e8c5aet76d5c012e32"));
reqEntity.addPart("grant_type",new StringBody("phone"));
reqEntity.addPart("device_token",new StringBody("5198a1385aa95a5a77660e889df26f11"));
} catch (Exception e) {
e.printStackTrace();
}
POST2meiPai(reqEntity,url,call);
}
示例3: POST2meiPai
import com.lidroid.xutils.http.client.multipart.MultipartEntity; //导入依赖的package包/类
/** 发送POST请求的真正工作者.
* @param reqEntity
* @param url
* @param call
*/
private static void POST2meiPai(final MultipartEntity reqEntity, final String url, final CallString call) {
Runnable runnable = new Runnable() {
@Override
public void run() {
HttpClient httpClient = new DefaultHttpClient();
HttpPost post = new HttpPost(url);
post.setEntity(reqEntity);
try {
HttpResponse response = httpClient.execute(post);
BufferedReader reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent(), "UTF-8"));
String sResponse;
StringBuilder s = new StringBuilder();
while ((sResponse = reader.readLine()) != null) {
s = s.append(sResponse);
}
call.getString(s.toString());
} catch (Exception e) {
e.printStackTrace();
}
}
};
ThreadPoolUtil.addThread(runnable);
}
示例4: upload
import com.lidroid.xutils.http.client.multipart.MultipartEntity; //导入依赖的package包/类
public void upload(final Context ctx, final String url, final String localPath, final PostCallbackIA postCBIA) {
//HttpUtils http = new HttpUtils(60 * 1000);
RequestParams params = new RequestParams();
MultipartEntity entity = new MultipartEntity();
entity.addPart("file", new FileBody(new File(localPath)));
params.setBodyEntity(entity);
getSingleInstance().send(HttpRequest.HttpMethod.POST,
url,
params,
new RequestCallBack<String>() {
@Override
public void onStart() {
//testTextView.setText("conn...");
}
@Override
public void onLoading(long total, long current, boolean isUploading) {
/*if (isUploading) {
testTextView.setText("upload: " + current + "/" + total);
} else {
testTextView.setText("reply: " + current + "/" + total);
}*/
}
@Override
public void onSuccess(ResponseInfo<String> responseInfo) {
postCBIA.onSuccess(responseInfo);
}
@Override
public void onFailure(HttpException error, String msg) {
postCBIA.onFailure(error, msg);
}
});
}
示例5: getVerifySMS
import com.lidroid.xutils.http.client.multipart.MultipartEntity; //导入依赖的package包/类
/**
* 获取短信验证码,已经在子线程中。n秒后重新发送验证码请重新调用我
*
* @param phoNum 电话号码
* @param pwd 密码
* @param call 返回信息的回调结果。
* 一切顺利返回的json中包含一个true
*/
public static void getVerifySMS(final String phoNum, final String pwd, final CallString call) {
String url = APIUtils.getSMSUrl;
MultipartEntity reqEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
try {
reqEntity.addPart("password", new StringBody(pwd));
reqEntity.addPart("device_id", new StringBody("864690025974851"));
reqEntity.addPart("client_id", new StringBody("1089857302"));
reqEntity.addPart("phone", new StringBody(phoNum));
} catch (Exception e) {
e.printStackTrace();
}
POST2meiPai(reqEntity, url, call);
}
示例6: FriendShipCreate
import com.lidroid.xutils.http.client.multipart.MultipartEntity; //导入依赖的package包/类
/** 通过ID关注用户
* @param access_token
* @param id
* @param call 成功返回"following": true,"followed_by": false
* 错误返回"error_code": 20506, "error": "已经关注过TA了"
*/
public static void FriendShipCreate(String access_token,String id,CallString call){
String url = APIUtils.getFriendShipCreate();
MultipartEntity reqEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
try {
reqEntity.addPart("access_token", new StringBody(access_token));
reqEntity.addPart("id", new StringBody(id));
} catch (Exception e) {
e.printStackTrace();
}
POST2meiPai(reqEntity,url,call);
}
示例7: FriendShipCancle
import com.lidroid.xutils.http.client.multipart.MultipartEntity; //导入依赖的package包/类
/** 通过ID取消关注
* @param access_token
* @param id
* @param call 成功返回 "following": false,"followed_by": false
* 失败返回"error_code": 20508,"error": "你还未关注此用户"
*/
public static void FriendShipCancle(String access_token,String id,CallString call){
String url = APIUtils.getFriendShipCancle();
MultipartEntity reqEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
try {
reqEntity.addPart("access_token", new StringBody(access_token));
reqEntity.addPart("id", new StringBody(id));
} catch (Exception e) {
e.printStackTrace();
}
POST2meiPai(reqEntity,url,call);
}
示例8: CommentCreate
import com.lidroid.xutils.http.client.multipart.MultipartEntity; //导入依赖的package包/类
/**发送评论方法
* @param access_token
* @param MediaId 要评论视频的ID
* @param comment 评论内容
* @param call 成功 返回一个单个的CommentBean的json,即刚刚发送的评论
* 错误 "error_code": 10107,"error": "系统错误",
*/
public static void CommentCreate(String access_token,String MediaId,String comment,CallString call){
String url = APIUtils.getCommentCreatLink();
MultipartEntity reqEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
try {
reqEntity.addPart("access_token", new StringBody(access_token));
reqEntity.addPart("id", new StringBody(MediaId));
reqEntity.addPart("comment",new StringBody(comment));
} catch (Exception e) {
e.printStackTrace();
}
POST2meiPai(reqEntity,url,call);
}
示例9: setCallBackInfo
import com.lidroid.xutils.http.client.multipart.MultipartEntity; //导入依赖的package包/类
@Override
public void setCallBackInfo(MultipartEntity.CallBackInfo callBackInfo) {
this.callBackInfo = callBackInfo;
}
示例10: setCallBackInfo
import com.lidroid.xutils.http.client.multipart.MultipartEntity; //导入依赖的package包/类
void setCallBackInfo(MultipartEntity.CallBackInfo callBackInfo);