firebase / firebase/quickstart-android
android firebase file upload in background service stopped when clear app from recents.
- Lingua principale
- Kotlin
- Stelle
- 9.3k
- Fork
- 7.4k
- Merge medio
- 2g 19h
- PR unite (30g)
- 8
Descrizione
### 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.
```java
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public class NotificationJobService extends JobService implements UploadFileToServer.UploadEventListener {
private JobStartedListner jobStartedListner;
ArrayList sourceFileList = new ArrayList();
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 sourceFileList, Context context) {
uploadFileToServer = new UploadFileToServer(uploadEventListener, /*new File(imagepath)*/sourceFileList, context);
}
@Override
public boolean onStopJob(JobParameters jobParameters) {
uploadFileToServer.cancel(true);
return true;
}
}
```
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Start with the NotificationJobService example in the issue, especially onStartJob and onStopJob, and trace how UploadFileToServer is created and cancelled when the app leaves recents. The payload names no repository file or test; done means background uploads and their notifications continue or fail visibly after the app is removed from recents.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- android, firebase, java
- Ambito
- mobile
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 25/100