Fixed clear for Android 14

This commit is contained in:
M66B 2023-10-14 10:16:32 +02:00
parent 6bda014ba4
commit 415c5d189b
2 changed files with 14 additions and 1 deletions

View File

@ -19,6 +19,7 @@ package eu.faircode.email;
Copyright 2018-2023 by Marcel Bokhorst (M66B)
*/
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
@ -60,4 +61,9 @@ public class ActivityClear extends ActivityBase {
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
Intent.FLAG_ACTIVITY_CLEAR_TASK);
}
static PendingIntent getPendingIntent(Context context) {
return PendingIntentCompat.getActivity(
context, 0, getIntent(context), PendingIntent.FLAG_UPDATE_CURRENT);
}
}

View File

@ -25,6 +25,13 @@ import android.os.Build;
@TargetApi(Build.VERSION_CODES.N)
public class ServiceTileClear extends ServiceTileBase {
public void onClick() {
startActivityAndCollapse(ActivityClear.getIntent(this));
try {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.UPSIDE_DOWN_CAKE)
startActivityAndCollapse(ActivityClear.getIntent(this));
else
startActivityAndCollapse(ActivityClear.getPendingIntent(this));
} catch (Throwable ex) {
Log.e(ex);
}
}
}