Stop using deprecated startActivityAndCollapse(Intent)

This commit is contained in:
Alexander Bakker 2023-12-27 17:45:28 +01:00
parent a1d00b47fe
commit 7c1a954e4d
3 changed files with 24 additions and 5 deletions

View file

@ -1,5 +1,7 @@
package com.beemdevelopment.aegis.services;
import android.annotation.SuppressLint;
import android.app.PendingIntent;
import android.content.Intent;
import android.os.Build;
import android.service.quicksettings.Tile;
@ -22,6 +24,7 @@ public class LaunchAppTileService extends TileService {
}
}
@SuppressLint("StartActivityAndCollapseDeprecated")
@Override
public void onClick() {
super.onClick();
@ -30,6 +33,12 @@ public class LaunchAppTileService extends TileService {
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
intent.setAction(Intent.ACTION_MAIN);
startActivityAndCollapse(intent);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
int flags = PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE;
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, flags);
startActivityAndCollapse(pendingIntent);
} else {
startActivityAndCollapse(intent);
}
}
}
}

View file

@ -1,5 +1,7 @@
package com.beemdevelopment.aegis.services;
import android.annotation.SuppressLint;
import android.app.PendingIntent;
import android.content.Intent;
import android.os.Build;
import android.service.quicksettings.Tile;
@ -22,6 +24,7 @@ public class LaunchScannerTileService extends TileService {
}
}
@SuppressLint("StartActivityAndCollapseDeprecated")
@Override
public void onClick() {
super.onClick();
@ -31,6 +34,12 @@ public class LaunchScannerTileService extends TileService {
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
intent.setAction(Intent.ACTION_MAIN);
startActivityAndCollapse(intent);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
int flags = PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE;
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, flags);
startActivityAndCollapse(pendingIntent);
} else {
startActivityAndCollapse(intent);
}
}
}
}

View file

@ -47,7 +47,8 @@ public class NotificationService extends Service {
.setOngoing(true)
.setContentIntent(pendingIntent);
startForeground(NOTIFICATION_VAULT_UNLOCKED, builder.build());
// NOTE: Disabled for now. See issue: #1047
//startForeground(NOTIFICATION_VAULT_UNLOCKED, builder.build());
}
@Override