点击通知导航到不同的活动 [英] Navigate to different activities on notification click

查看:58
本文介绍了点击通知导航到不同的活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当用户点击通知时我有这种情况,如果应用程序打开/前台我想将用户重定向到 HomeActivity 否则将用户重定向到 SplashActivity 作为我正在那里执行一些身份验证任务.那么,实现这一目标的最佳和正确方法是什么??

I have this scenario when user clicks the notification then, if the app is opened/foreground I want to redirect the user to HomeActivity else redirect the user to SplashActivity as I am performing some authentication tasks there. So, what is the best and proper way to achieve this??

我知道有很多相关的问题,但我没有找到任何特定于我的用例

I know there are lot of related questions but I haven't found anything specific to my usecase

推荐答案

在本论坛中搜索后我得到了这个 post ,从中得到一些指导,我找到了一个解决方案,在点击通知时,我将每个意图重定向到 HomeActivity 并在 onCreate() 中放置我的代码以检查身份验证是否已完成(在 setContentView() 之前).如果未完成身份验证,则重定向到 SplashActivity 并完成当前活动,否则继续.

After some searching in this forum I got this post , taking some guidance from that I figured out a solution, on notification click I am redirecting every intent to HomeActivity and in onCreate() put my code to check if authentication is done or not(before setContentView()). If the authentication is not done redirect to SplashActivity and finish the current activity, otherwise continue.

这篇关于点击通知导航到不同的活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆