Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ServiceCompat.stopForeground(). #5218

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/src/main/java/org/schabi/newpipe/RouterActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.content.res.AppCompatResources;
import androidx.core.app.NotificationCompat;
import androidx.core.app.ServiceCompat;
import androidx.core.widget.TextViewCompat;
import androidx.fragment.app.FragmentManager;
import androidx.preference.PreferenceManager;
Expand Down Expand Up @@ -695,7 +696,7 @@ public Consumer<Info> getResultHandler(final Choice choice) {
@Override
public void onDestroy() {
super.onDestroy();
stopForeground(true);
ServiceCompat.stopForeground(this, ServiceCompat.STOP_FOREGROUND_REMOVE);
if (fetcher != null) {
fetcher.dispose();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import android.os.IBinder
import android.util.Log
import androidx.core.app.NotificationCompat
import androidx.core.app.NotificationManagerCompat
import androidx.core.app.ServiceCompat
import androidx.preference.PreferenceManager
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
import io.reactivex.rxjava3.core.Flowable
Expand Down Expand Up @@ -147,7 +148,7 @@ class FeedLoadService : Service() {

private fun stopService() {
disposeAll()
stopForeground(true)
ServiceCompat.stopForeground(this, ServiceCompat.STOP_FOREGROUND_REMOVE)
notificationManager.cancel(NOTIFICATION_ID)
stopSelf()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import androidx.annotation.StringRes;
import androidx.core.app.NotificationCompat;
import androidx.core.app.NotificationManagerCompat;
import androidx.core.app.ServiceCompat;

import org.reactivestreams.Publisher;
import org.schabi.newpipe.R;
Expand Down Expand Up @@ -162,7 +163,7 @@ protected void stopAndReportError(@Nullable final Throwable error, final String

protected void postErrorResult(final String title, final String text) {
disposeAll();
stopForeground(true);
ServiceCompat.stopForeground(this, ServiceCompat.STOP_FOREGROUND_REMOVE);
stopSelf();

if (title == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import androidx.annotation.StringRes;
import androidx.core.app.NotificationCompat;
import androidx.core.app.NotificationManagerCompat;
import androidx.core.app.ServiceCompat;
import androidx.core.content.ContextCompat;

import org.schabi.newpipe.MainActivity;
Expand Down Expand Up @@ -188,7 +189,7 @@ void createNotificationAndStartForeground(final VideoPlayerImpl player, final Se
}

void cancelNotificationAndStopForeground(final Service service) {
service.stopForeground(true);
ServiceCompat.stopForeground(service, ServiceCompat.STOP_FOREGROUND_REMOVE);

if (notificationManager != null) {
notificationManager.cancel(NOTIFICATION_ID);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import android.os.Message;
import android.os.Parcelable;

import androidx.core.app.ServiceCompat;
import androidx.core.content.ContextCompat;
import androidx.preference.PreferenceManager;
import android.util.Log;
Expand Down Expand Up @@ -235,7 +236,7 @@ public void onDestroy() {
Log.d(TAG, "Destroying");
}

stopForeground(true);
ServiceCompat.stopForeground(this, ServiceCompat.STOP_FOREGROUND_REMOVE);

if (mNotificationManager != null && downloadDoneNotification != null) {
downloadDoneNotification.setDeleteIntent(null);// prevent NewPipe running when is killed, cleared from recent, etc
Expand Down Expand Up @@ -363,7 +364,7 @@ public void updateForegroundState(boolean state) {
if (state) {
startForeground(FOREGROUND_NOTIFICATION_ID, mNotification);
} else {
stopForeground(true);
ServiceCompat.stopForeground(this, ServiceCompat.STOP_FOREGROUND_REMOVE);
}

manageLock(state);
Expand Down