Java 未调用android通知PendingEvent OnneWinEvent

Java 未调用android通知PendingEvent OnneWinEvent,java,android,Java,Android,我想在按下fcm通知时调用onNewIntent()方法 我读了一些关于这方面的问答,我认为我的代码很简单 但它不起作用。我不知道怎么了:( 这是我的密码 FCM: onNewIntent(): 并表明: <activity android:name=".MainActivity" android:launchMode="singleTop"> logcat中只有两个错误: 07-25 18:38:18.216 25648-25648/?E/合子:v2

我想在按下fcm通知时调用onNewIntent()方法

我读了一些关于这方面的问答,我认为我的代码很简单

但它不起作用。我不知道怎么了:(

这是我的密码

FCM:

onNewIntent():

并表明:

    <activity android:name=".MainActivity"
        android:launchMode="singleTop">

logcat中只有两个错误:

07-25 18:38:18.216 25648-25648/?E/合子:v2


07-25 18:38:18.221 25648-25648/?E/合子:访问信息:0

重新发布我在此处找到的解决方案:

添加以下行:

intent.setAction(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_LAUNCHER);

我不知道为什么必须设置它们,但如果不设置它们,则不会调用OnEvent。

试试这个……Intent Intent Intent=新Intent(this,MainActivity.class);Intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);Intent.addFlags(Intent.FLAG_ACTIVITY_new_TASK);startActivity(Intent);谢谢您的评论!但这对我不起作用。t发布日志猫错误的屏幕截图,请阅读。我在启动应用程序后在日志猫中发布错误,直到按下noti键激活Mainactivity。使用“活动”标记重新排序到前面,请阅读此文档。。
    <activity android:name=".MainActivity"
        android:launchMode="singleTop">
intent.setAction(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_LAUNCHER);