我正在开发一个应用程序,用户必须在使用该应用程序之前注册他/她自己。我在注册时发送的参数很少。还有一个imageview ..我正在做这个代码
imgvw1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
selectImage();
}
});
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
btn_submit.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if(name.getText().toString().trim().length()>0 )
{
if(pass.getText().toString().trim().length()>0)
{
if(email.getText().toString().trim().length()>0)
{
if(age.getText().toString().trim().length()>0)
{
String regName = name.getText().toString().trim();
String regPass = pass.getText().toString().trim();
String regEmail = email.getText().toString().trim();
String regAge = age.getText().toString().trim();
String url ="http://tokerapp.com/ws/register.php?username="+ regName + "&password=" + regPass + "&email=" + regEmail + "&age=" + regAge + "&sex=qee&Device_Id=12332weewr";
try {
ArrayList<NameValuePair> postParameters = new ArrayList<NameValuePair>();
// ArrayList<NameValuePair> nameValuePairs = null;
postParameters.add(new BasicNameValuePair("file", "<thumbnail>"));
String res= CustomHttpClient.executeHttpPost(url, postParameters);
Log.e("response",""+res);
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
}
else
{
Toast.makeText(getApplicationContext(), "Invalid Entry", 1000).show();
}
}
}
);
}
protected void selectImage() {
// TODO Auto-generated method stub
final CharSequence[] options = { "Choose from Gallery","Cancel" };
AlertDialog.Builder builder = new AlertDialog.Builder(Registration.this);
builder.setTitle("Add Photo!");
builder.setItems(options, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int item) {
/*if (options[item].equals("Take Photo"))
{
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
File f = new File(android.os.Environment.getExternalStorageDirectory(), "temp.jpg");
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(f));
startActivityForResult(intent, 1);
}*/
if (options[item].equals("Choose from Gallery"))
{
Intent intent = new Intent(Intent.ACTION_PICK,android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(intent, 1);
}
else if (options[item].equals("Cancel")) {
dialog.dismiss();
}
}
});
builder.show();
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_OK)
{
if (requestCode == 1)
{
Uri selectedImage = data.getData();
String[] filePath = { MediaStore.Images.Media.DATA };
Cursor c = getContentResolver().query(selectedImage,filePath, null, null, null);
c.moveToFirst();
int columnIndex = c.getColumnIndex(filePath[0]);
String picturePath = c.getString(columnIndex);
c.close();
Bitmap thumbnail = (BitmapFactory.decodeFile(picturePath));
Log.w("path of image from gallery......******************.........", picturePath+"");
imgvw1.setImageBitmap(thumbnail);
}
}
}
//}
}
并从webservice获得此响应。
{“message”:“图片未上传”,“状态”:“STATUS_FALSE”}
请帮我解决这个问题,谢谢你提前