小编Kri*_*adi的帖子

前台工作人员中的多个通知

我正在使用工作人员管理器上传视频和通知。当用户尝试使用正在进行的上传工作者作业再次上传视频时,即使正在执行工作,也不会显示第二次上传的通知。我使用的是独特的通知ID,并呼吁setForegroundAsync提到这里。我希望为提交的每个视频上传工作显示通知。

PS抱歉我的英语不好。谢谢

public class PostUploadWorker extends Worker {


    private PostDao postDao;

    private AppPref appPref;

    private HttpLoggingInterceptor logging;

    private PostEntity postEntity;

    private NotificationManagerCompat notificationManager;

    private Bitmap videoThumbnail = null;

    public PostUploadWorker(@NonNull Context context, @NonNull WorkerParameters workerParams, @NonNull HttpLoggingInterceptor logging, @NonNull AppPref appPref,
                            @NonNull PostDao postDao) {
        super(context, workerParams);
        this.logging = logging;
        this.appPref = appPref;
        this.postDao = postDao;
        this.notificationManager = NotificationManagerCompat.from(getApplicationContext());
    }

    @NonNull
    @Override
    public Result doWork() {
        // Inject fields
        long postId = getInputData().getLong(Constants.INTENT_POST_ID, -1);

        // upload post
        if …
Run Code Online (Sandbox Code Playgroud)

android worker foregroundnotification android-workmanager

6
推荐指数
0
解决办法
67
查看次数