简体   繁体   English

单击推送通知时的活动(Android)

[英]Activity when push notification is clicked (Android)

I am using push notifications from backendless and I can recieve the notification but when I receive push notification and I click on it in the app bar it automatically redirects me to the main activity. 我正在使用来自后端的推送通知,我可以接收该通知,但是当我收到推送通知并在应用程序栏中单击它时,它将自动将我重定向到主要活动。

I want it to redirect to the open another activity when I click on the push notification. 当我单击推送通知时,我希望它重定向到打开另一个活动。

I searched for the problem and found that I have to add the following lines in the Android Mainfest file in the activity that I want to open. 我搜索了问题,发现我必须在要打开的活动中的Android Mainfest文件中添加以下行。

<activity android:name=".ShowMessage">

<intent-filter>

<action android:name="com.example.user.notificationfromc.MESSAGE"/>

<category android:name="android.intent.category.DEFAULT"/>

</intent-filter>

</activity>

(com.example.user.notificationfromc.) is my package name (com.example.user.notificationfromc。)是我的软件包名称

(ShowMessage) is the activity that I want to open. (ShowMessage)是我要打开的活动。

But it does not work. 但这行不通。

try this. 尝试这个。

Intent notificationIntent = new Intent(context, YourActivity.class);
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP|Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent intent = PendingIntent.getActivity(context, 0, notificationIntent, 0);
yourNotification.setLatestEventInfo(context, title, message, intent);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Android - Firebase 通知在点击时打开一个活动 - Android - Firebase Notification open an Activity when clicked 单击推送通知时,特定活动不会打开 - when push notification clicked, specific activity doesn't open 点击推送通知时意图进行特定活动。 - intent to specific activity when push notification clicked in. 在android / Xamarin.Android中单击通知时切换到运行活动 - switch to running activity when notification clicked in android/Xamarin.Android 单击推送通知后的打开活动 - Open activity after push notification clicked 单击 Android Firebase 推送通知会重新启动应用程序 - Android Firebase Push notification restarts app when clicked Android,用户在单击按钮时发送推送通知 - Android, user send push notification when button clicked 单击通知后在后台运行应用程序时,Android推送不会触发 - Android push does not trigger when app in background after notification clicked 在Android中单击时如何防止通知打开活动或将其删除? - How to prevent notification from opening an activity or removed when clicked in Android? 在Android 4.0版上单击通知时,永远不会启动Activity - Activity is never launched when the notification is clicked on android version 4.0
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM