我已经尝试了很多,但在上传时显示通知的进度却没有成功。我可以使用Asynch Task将数据上传到服务器,但现在我需要将数据上传到服务器并显示在通知栏中,就像我们在Facebook上传图像或视频一样。
我无法做到这一点。我通过asynch上传数据的代码如下。
我在doInBackGround()方法中编写下面的代码:
HttpClient httpClient = new DefaultHttpClient();
HttpPost postRequest = new HttpPost(
"http://********.php?f=setAvatar");
ByteArrayBody bab = new ByteArrayBody(data, "receipt.jpg");
// File file= new File("/mnt/sdcard/forest.png");
// FileBody bin = new FileBody(file);
File file = new File(ProfileEdit.selectedImagePath);
MultipartEntity reqEntity = new MultipartEntity(
HttpMultipartMode.BROWSER_COMPATIBLE);
ContentBody cbFile = new FileBody(file, "image/jpeg");
reqEntity.addPart("im", cbFile);
reqEntity.addPart("u", new StringBody(USERID));
reqEntity.addPart("k", new StringBody(KEY));
reqEntity.addPart("p", new StringBody(pannelId));
//reqEntity.addPart("id", new StringBody(password));
//reqEntity.addPart("addExpenseResult", new StringBody(expenceresult));
postRequest.setEntity(reqEntity);
HttpResponse response = httpClient.execute(postRequest);
BufferedReader reader = new BufferedReader(new InputStreamReader(
response.getEntity().getContent(), "UTF-8"));
String sResponse;
StringBuilder s = new StringBuilder();
答案 0 :(得分:0)
您可以使用RemoteView
和PendingIntent
在通知栏上显示,请参阅:http://developer.android.com/guide/topics/ui/notifiers/notifications.html#CustomExpandedView
了解详细进展,I need know how much bytes has been uploaded for update a progress bar android