我希望能够在没有任何用户操作的情况下收到推送通知时在应用程序中打开活动 . 是否可以使用信号或其他方式使用推送自动打开应用程序?
你可以试试这个,希望这段代码能帮到你 .
Intent restart = context.getPackageManager() . getLaunchIntentForPackage(context.getPackageName()); restart.addFlags(意图. enter code here FLAG_ACTIVITY_CLEAR_TOP); context.startActivity(重启);
enter code here
您只需在 FirebaseMessagingService.onMessageReceived 内启动您的家庭活动但是如果应用程序当前正在运行,则您不必这样做 . 你需要一种控制器和检查应用程序foreground
FirebaseMessagingService.onMessageReceived
2 回答
你可以试试这个,希望这段代码能帮到你 .
Intent restart = context.getPackageManager() . getLaunchIntentForPackage(context.getPackageName()); restart.addFlags(意图.
enter code here
FLAG_ACTIVITY_CLEAR_TOP); context.startActivity(重启);您只需在
FirebaseMessagingService.onMessageReceived
内启动您的家庭活动但是如果应用程序当前正在运行,则您不必这样做 . 你需要一种控制器和检查应用程序foreground