android firebase file upload in background service stopped when clear app from recents.

オープン
#781 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
25/100
issue の種類
バグ
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
android, firebase, java
領域
mobile

調査の方向性

Issue の NotificationJobService の例、特に onStartJob と onStopJob から始め、アプリが最近使ったアプリから削除されたときに UploadFileToServer がどのように作成され、キャンセルされるかを追跡します。payload ではリポジトリのファイルもテストも指定されていません。完了条件は、アプリが最近使ったアプリから削除された後もバックグラウンドアップロードとその通知が継続するか、目に見える形で失敗することです。

索引モデルが issue の本文から書いたものです。

説明

api: storage type: bug
Step 1: Are you in the right place?
  • For issues or feature requests related to the code android storage file a Github issue.
Step 2: Describe your environment
  • Android device: _____Mi note5
  • Android OS version: _____oreo
  • Google Play Services version: _____
  • Firebase/Play Services SDK version: _____
Step 3: Describe the problem:

I have used your code for file upload in background service. It works fine when the app is running. but when the app is removed from recent apps or get killed then the uploading and notification stopped and remains as it is.

@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public class NotificationJobService extends JobService implements UploadFileToServer.UploadEventListener {
    private JobStartedListner jobStartedListner;
    ArrayList<File> sourceFileList = new ArrayList<File>();
    UploadFileToServer uploadFileToServer;

    @Override
    public void onPreExecute() {

    }

    @Override
    public void onComplete() {

    }

    @Override
    public void onProgressUpdated(Integer progress, int totalSize, int currentFilePosition) {

    }

    public interface JobStartedListner {
        public void onJobStarted();
    }

    public NotificationJobService() {
    }

    @Override
    public boolean onStartJob(JobParameters jobParameters) {
        Log.e("Job Params", jobParameters.toString());
        String[] data = jobParameters.getExtras().getStringArray("data");
        for (int i = 0; i < data.length; i++) {
            if (data[i] != null) {
                File f = new File(data[i]);
                sourceFileList.add(new File(data[i]));
            }
        }
        uploadFiles(this, sourceFileList, this);
        return false;
    }

    public void uploadFiles(UploadFileToServer.UploadEventListener uploadEventListener, ArrayList<File> sourceFileList, Context context) {
        uploadFileToServer = new UploadFileToServer(uploadEventListener, /*new File(imagepath)*/sourceFileList, context);
    }

    @Override
    public boolean onStopJob(JobParameters jobParameters) {
        uploadFileToServer.cancel(true);
        return true;
    }
}
主要言語
Kotlin
スター
9.3k
フォーク
7.4k
平均マージ
7日 9時間
マージ済み PR(30日)
6

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

firebase/quickstart-android のほかの issue

firebase/quickstart-android の issue をすべて見る

似ている issue

Kotlin の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。