android 获取上传进度条,android 实现Service上传并在通知栏显示进度条

手上项目需要实现选择多个视频后在上传腾讯云,由于视频较大大,所以选择Service来进行上传任务,配合Notification显示进度。

NotificationManager mNotificationManager;

RemoteViews view;

List paths; //需要上传的视频地址

Notification notification;

int notifyid = 30001; //自己设置就好

@Override

public int onStartCommand(Intent intent,int flags,int startId) {

paths = intent.getStringArrayListExtra("paths");

String channelid="com.lianqin.upload";

mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);

if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {

//android8.0 增加了渠道,如果不设置,在8.0下是无法显示通知的,channelid自己定义就好,渠道名会显示在系统设置-app的通知管理下

NotificationChannel Channe =new NotificationChannel(channelid,

"上传服务", NotificationManager.IMPORTANCE_HIGH);

mNotificat

你可能感兴趣的:(android,获取上传进度条)