我通過從圖庫中選擇圖像或使用安卓相機捕獲圖像將圖像上傳到網絡服務器。在上傳圖片到服務器的通知欄中的進度條在android
我需要在通知欄中顯示一個程序。我看到Facebook應用程序這樣做。有沒有辦法找出多少上傳?
我的圖像上傳到服務器的代碼是:
public void uploadImage() {
final Toast toast = Toast.makeText(this, "Image uploaded successfully",
Toast.LENGTH_SHORT);
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Upload");
builder.setMessage("Do you want to upload the captured picture?");
builder.setIcon(R.drawable.icon);
builder.setCancelable(false);
builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
testWebService(Bitmap bmp)
finish();
toast.show();
}
});
builder.setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
AlertDialog alert = builder.create();
alert.show();
}
public void testWebService(Bitmap bmp) {
MarshalBase64 marshal = new MarshalBase64();
ByteArrayOutputStream out = new ByteArrayOutputStream();
bmp.compress(CompressFormat.PNG, 100, out);
byte[] raw = out.toByteArray();
SoapObject request = new SoapObject(WSDL_TARGET_NAMESPACE,
OPERATION_NAME);
request.addProperty("image", raw);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
marshal.register(envelope);
HttpTransportSE httpTransport = new HttpTransportSE(SOAP_ADDRESS);
try
{
httpTransport.call(SOAP_ACTION, envelope);
Object response = envelope.getResponse();
}
catch (Exception exception)
{
exception.printStackTrace();
}
}
是有辦法找出多少已經上傳???
我想做同樣的事情從內置攝像頭捕獲圖像並將其發送到服務器。我可以問你是如何連接攝像頭圖像和上傳部分的?你使用什麼方法在Web服務器部分接收圖像? 該方法是否有byte []參數? 我有一個沒有參數的方法,它會生成一個隨機數。那麼我怎樣才能使這兩者之間的聯繫?發送圖像並返回一個隨機數字? 請幫忙!! 謝謝。 – Michiru 2011-06-02 18:03:53
@jennifer:正如你已經解決了這個問題,我可以知道你是如何得到正在上傳的字節數組的數量? – Junaid 2011-11-15 08:37:10
Junaid我在Android上使用多部分表格上傳 http://www.17od.com/2010/02/18/multipart-form-upload-on-android/ – jennifer 2011-11-21 10:53:41