通过 Android 15 BAL 强化,如果 PI 创建者将 target_sdk 升级到 35+ 并且 PI 发送者将 target_sdk 升级到 34+,则此活动启动可能会被阻止! [调用包:com.android.shell;呼叫ID:2000;呼叫号码:8295;应用程序开关状态:2;调用UidHasAnyVisibleWindow: false;调用UidProcState:CACHED_EMPTY; isCallingUidPersistentSystemProcess: false;强制BalByPiSender:BSP.NONE;意图:意图 { act=android.intent.action.MAIN cat=[android.intent.category.DEFAULT] flg=0x10000000 cmp=com.vpn.enter/.SplashActivity };来电者应用程序:空; balAllowedByPiCreator:BSP.ALLOW_BAL; resultIfPiCreatorAllowsBal: BAL_ALLOW_PERMISSION; hasRealCaller:真; isPendingIntent:假; realCallingPackage: android.uid.shell:2000[debugOnly]; realCallingUid: 2000;真实呼叫 ID:8295; realCallingUidHasAnyVisibleWindow: false; realCallingUidProcState:CACHED_EMPTY; isRealCallingUidPersistentSystemProcess: false; originatingPendingIntent:空; realCallerApp:空; balAllowedByPiSender:BSP.ALLOW_FGS; resultIfPiSenderAllowsBal:BAL_ALLOW_PERMISSION]
为了解决这个问题,
PendingIntent
必须选择后台活动启动。这是我的代码。我正在处理一个遗留文件,因此我的代码是java
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent,
PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE, getActivityOptionsBundle());
private static Bundle getActivityOptionsBundle() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
ActivityOptions activityOptions = ActivityOptions.makeBasic();
activityOptions.setPendingIntentBackgroundActivityStartMode(ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOWED);
return activityOptions.toBundle();
} else
return null;
}
检查文档 https://developer.android.com/guide/components/activities/background-starts#opt-in-required