简体   繁体   English

我可以使用Android推送通知在我的Android应用中设置值

[英]Can I use an Android Push Notification to set a value in my Android App

I have an Android App I am building and I want to do something similar to what iOS does when you push a notification the app will launch in the background and perform a task then go back to sleep. 我有一个正在构建的Android应用程序,我想做的事情类似于iOS,当您推送通知时,该应用程序将在后台启动并执行任务,然后返回睡眠状态。 I want to do this be cause I need to set a application value that tracks new content added since the last time the user opens my app. 之所以要这样做,是因为我需要设置一个应用程序值,以跟踪自用户上次打开我的应用程序以来添加的新内容。

So if I send 3 push notifications and 2 are notifying the user about new content in area "A" and the other is notifying the user about new content in a area "B", then I want to increment some application values every time a notification is received. 因此,如果我发送3个推送通知,而2个正在通知用户“ A”区域中的新内容,而另一个正在通知用户有关“ B”区域中的新内容,那么我想每次通知时增加一些应用程序值收到。 Then when the app opens I can bring attention to the areas with updated content. 然后,当应用程序打开时,我可以引起注意具有更新内容的区域。

If there isn't a way to do this with push notifications I could always set up some sort of update reference table that my app would have to check upon opening to get the update counts since last launch. 如果没有办法通过推送通知执行此操作,那么我总是可以设置某种更新参考表,我的应用程序在打开时必须进行检查以获取自上次启动以来的更新计数。

Thanks, Fissh 谢谢菲丝

Yes you can do this all. 是的,您可以全部完成。

  1. While you receive push at that place get all data and do operation on it for update. 当您在该位置收到推送时,获取所有数据并对其进行操作以进行更新。
  2. But first take care of that data should be store in preference because if you store in simple variable then it will erase after finish or close application so store data in preference and call this preference while you want to use this data. 但是首先要注意该数据应优先存储,因为如果存储在简单变量中,则它将在完成或关闭应用程序后擦除,因此请优先存储数据并在要使用此数据时调用此优先级。

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

相关问题 我可以设置Google Assistant以使用Dialogflow向我的Android应用发送推送通知吗? - Can I set up Google Assistant to send a push notification to my Android app using Dialogflow? 当我的 Xamarin Android 应用程序停止时,如何接收推送通知? - How can I receive a Push Notification when my Xamarin Android app is stopped? 适用于iPhone和Android的文本应用程序的推送通知 - Push notification for my text app for iPhone and Android 我可以下载音频文件并将其用于Android中的推送通知声音吗? - Can I download an audio file and use it for push notification sound in Android? 在android中设置推送通知 - Set Push Notification in android 在Android应用中推送通知 - push notification in android app 我应该在Android中使用什么来进行推送通知 - What should I Use for push notification in android 如何以编程方式使用 android studio 4.2.1 将我的应用程序图标设置为一个信号通知 - How can i set my app icon to one signal notification using android studio 4.2.1 programatically 我想在我的Android应用中使用“解析通知” - I Want to Use “Parse Notification” in my Android App 有没有办法设置从Google日历到我的Android应用的推送通知? - Is there a way to set up a push notification from Google Calendar to my android app?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM