我正在通过WIFI向服务器发送信息,一切都很好.现在我也想将信息发送到带有移动数据的服务器,我不知道为什么只适用于WIFI,移动数据流程异常无法连接到服务器.
这是移动数据失败的部分; 与WIFI完美结合:
int length=values.length();
HttpParams httpParams = new BasicHttpParams();
HttpConnectionParams.setConnectionTimeout(httpParams,9000);
HttpConnectionParams.setSoTimeout(httpParams, 9000);
HttpClient client = new DefaultHttpClient(httpParams);
String url = saveData+"?Length="+length+"&Table="+temp;
HttpPost request = new HttpPost(url);
request.setEntity(new ByteArrayEntity(values.toString().getBytes("UTF8")));
request.setHeader("json", values.toString());
HttpResponse response = client.execute(request);
HttpEntity entity = response.getEntity();
// If the response does not enclose an entity, there is no need
Log.d("test 7","test 7 last");
if (entity != null) {
InputStream instream = entity.getContent();
String result = RestClient.convertStreamToString(instream);
Log.d("here",""+result);
if(result.equals("success")&& ReadyOff==false){
Ready=true;
}else{
Ready=false;
ReadyOff=true;
}
Log.d("sent","valor de ready"+Ready); …Run Code Online (Sandbox Code Playgroud) 我想用相机拍摄图像并将其保存到图片文件夹中...我唯一无法解决的问题是为什么我的图像以小尺寸保存...
Intent i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(i, TAKE_PICTURE);
protected void onActivityResult(int requestCode, int resultCode, Intent imageReturned) {
super.onActivityResult(requestCode, resultCode, imageReturned);
switch(requestCode) {
case TAKE_PICTURE:
if(resultCode == RESULT_OK)
{
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
photo.compress(Bitmap.CompressFormat.PNG, 100, bytes);
File f = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES)+ File.separator + "test3.png");
try {
f.createNewFile();
//write the bytes in file
FileOutputStream fo = new FileOutputStream(f);
fo.write(bytes.toByteArray());
fo.flush();
// remember close de FileOutput
fo.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
Run Code Online (Sandbox Code Playgroud)