[英]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.