我希望我的应用程序将图像上传到Web服务器.那部分有效.
我想知道是否可以通过在"通知栏"中输入条目来以某种方式显示上传的进度.我看到Facebook应用就是这么做的.
当你拍照并选择上传时,该应用程序可让你继续,并以某种方式将图片上传通知放在通知栏的进度条中.我觉得这很漂亮.我猜他们会产生一个新的服务或其他东西来处理上传,并经常更新通知栏中的进度条.
谢谢你的任何想法
Pao*_*lli 20
在Android中,为了在通知中显示进度条,您只需要将setProgress(...)初始化为Notification.Builder.
请注意,在您的情况下,您可能希望甚至使用setOngoing(true)标志.
Integer notificationID = 100;
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
//Set notification information:
Notification.Builder notificationBuilder = new Notification.Builder(getApplicationContext());
notificationBuilder.setOngoing(true)
.setContentTitle("Notification Content Title")
.setContentText("Notification Content Text")
.setProgress(100, 0, false);
//Send the notification:
Notification notification = notificationBuilder.build();
notificationManager.notify(notificationID, notification);
Run Code Online (Sandbox Code Playgroud)
然后,您的服务必须通知进度.假设您将(百分比)进度存储到名为progress的Integer中(例如progress = 10):
//Update notification information:
notificationBuilder.setProgress(100, progress, false);
//Send the notification:
notification = notificationBuilder.build();
notificationManager.notify(notificationID, notification);
Run Code Online (Sandbox Code Playgroud)
您可以在API通知页面上找到更多信息:http://developer.android.com/guide/topics/ui/notifiers/notifications.html#Progress
| 归档时间: |
|
| 查看次数: |
54984 次 |
| 最近记录: |