<i id='QskZ6'><tr id='QskZ6'><dt id='QskZ6'><q id='QskZ6'><span id='QskZ6'><b id='QskZ6'><form id='QskZ6'><ins id='QskZ6'></ins><ul id='QskZ6'></ul><sub id='QskZ6'></sub></form><legend id='QskZ6'></legend><bdo id='QskZ6'><pre id='QskZ6'><center id='QskZ6'></center></pre></bdo></b><th id='QskZ6'></th></span></q></dt></tr></i><div id='QskZ6'><tfoot id='QskZ6'></tfoot><dl id='QskZ6'><fieldset id='QskZ6'></fieldset></dl></div>
      <legend id='QskZ6'><style id='QskZ6'><dir id='QskZ6'><q id='QskZ6'></q></dir></style></legend>

      <small id='QskZ6'></small><noframes id='QskZ6'>

      1. <tfoot id='QskZ6'></tfoot>
        • <bdo id='QskZ6'></bdo><ul id='QskZ6'></ul>
      2. 即使应用程序关闭(滑动/滑动)也能接收 GCM 通知

        时间:2023-07-30

              <tbody id='MYegS'></tbody>
            • <bdo id='MYegS'></bdo><ul id='MYegS'></ul>
            • <tfoot id='MYegS'></tfoot>
              <i id='MYegS'><tr id='MYegS'><dt id='MYegS'><q id='MYegS'><span id='MYegS'><b id='MYegS'><form id='MYegS'><ins id='MYegS'></ins><ul id='MYegS'></ul><sub id='MYegS'></sub></form><legend id='MYegS'></legend><bdo id='MYegS'><pre id='MYegS'><center id='MYegS'></center></pre></bdo></b><th id='MYegS'></th></span></q></dt></tr></i><div id='MYegS'><tfoot id='MYegS'></tfoot><dl id='MYegS'><fieldset id='MYegS'></fieldset></dl></div>

                <small id='MYegS'></small><noframes id='MYegS'>

                <legend id='MYegS'><style id='MYegS'><dir id='MYegS'><q id='MYegS'></q></dir></style></legend>

                1. 本文介绍了即使应用程序关闭(滑动/滑动)也能接收 GCM 通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  这是在我的 MainActivity 中用作 BroadcastReceiver 的代码

                  Here is the code that is used as BroadcastReceiver inside my MainActivity

                      mRegistrationBroadcastReceiver = new BroadcastReceiver() {
                  
                          //When the broadcast received
                          //We are sending the broadcast from GCMRegistrationIntentService
                  
                          @Override
                          public void onReceive(Context context, Intent intent) {
                              //If the broadcast has received with success
                              //that means device is registered successfully
                              if(intent.getAction().equals(GCMRegistrationIntentService.REGISTRATION_SUCCESS)){
                                  //Getting the registration token from the intent
                                  String token = intent.getStringExtra("token");
                                  //Displaying the token as toast
                                  Toast.makeText(getApplicationContext(), "Registration token:" + token, Toast.LENGTH_LONG).show();
                  
                                  //if the intent is not with success then displaying error messages
                              } else if(intent.getAction().equals(GCMRegistrationIntentService.REGISTRATION_ERROR)){
                                  Toast.makeText(getApplicationContext(), "GCM registration error!", Toast.LENGTH_LONG).show();
                              } else {
                                  Toast.makeText(getApplicationContext(), "Error occurred", Toast.LENGTH_LONG).show();
                              }
                          }
                      };
                  

                  我学习了这个关于 GCM 的教程

                  I followed this tutorial about GCM

                  https://www.simplifiedcoding.net/android-push-notification-using-gcm-tutorial/

                  推荐答案

                  通过滑动关闭应用(通常称为滑动它)并不完全杀死应用程序.查看 Android 爱好者社区中的此答案,了解更详细的说明.你可以看到那里提到:

                  Closing the app by sliding it (more commonly known as swiping it away) doesn't totally kill the app. Check out this answer in Android Enthusiasts community for a more detailed description. You can see there that it is mentioned that:

                  ..它不会直接导致服务停止..

                  ..It won't directly causes services to stop..

                  由于 GCM 通知的侦听器是 Service,这实际上意味着您的应用仍有可能继续接收它们,无论它是否被刷掉.

                  Since listeners for GCM notifications are Services, this would actually mean that there is still a possibility that your app may still continue to receive them regardless if it is swiped away.

                  虽然滑动应用的结果也可能会有所不同取决于正在运行的设备,但可能会杀死/强制停止它,或者如上所述,会停止后台进程.

                  Though the result of swiping an app may also differ depending on the device it is running, one may kill/force stop it or other just as mentioned above, will stop background processes.

                  但是,如果结果是,应用程序被杀死/强制停止,如上面链接的答案中所述:

                  If the result is, however, the app is killed/force stopped, as mentioned in the answer from the link above:

                  对于停止是完全终止应用程序 - 所有进程都被终止,所有服务停止,所有通知被移除,所有警报被移除,等等.

                  For stop is a complete kill of the app -- all processes are killed, all services stopped, all notifications removed, all alarms removed, etc.

                  这将导致应用程序根本不会收到任何类型的通知,因为它是从 3.1 版开始为 Android 设计的,如本 回答:

                  Which would result for the app to don't receive any kind of notifications at all, as it was designed for Android since version 3.1, as stated in this answer:

                  处于停止状态的应用不会收到广播 Intent.

                  停止状态是:

                  最初安装应用时(在用户在应用中运行某些内容之前)或强制停止后.您可以在此处找到更多相关信息:http://developer.android.com/about/versions/android-3.1.html#launchcontrols

                  when the app is initially installed (before the user runs something in the app) or after a Force Stop. You can find more about this here: http://developer.android.com/about/versions/android-3.1.html#launchcontrols

                  希望这有助于以某种方式清除一些东西.干杯!:D

                  Hope this helps clear some things somehow. Cheers! :D

                  这篇关于即使应用程序关闭(滑动/滑动)也能接收 GCM 通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Firebase (FCM):打开活动并在通知点击时传递数据.安卓 下一篇:在 FCM 中单击通知时打开特定的 Activity

                  相关文章

                  <legend id='3hWhS'><style id='3hWhS'><dir id='3hWhS'><q id='3hWhS'></q></dir></style></legend>

                  1. <small id='3hWhS'></small><noframes id='3hWhS'>

                        <bdo id='3hWhS'></bdo><ul id='3hWhS'></ul>
                    1. <tfoot id='3hWhS'></tfoot>
                    2. <i id='3hWhS'><tr id='3hWhS'><dt id='3hWhS'><q id='3hWhS'><span id='3hWhS'><b id='3hWhS'><form id='3hWhS'><ins id='3hWhS'></ins><ul id='3hWhS'></ul><sub id='3hWhS'></sub></form><legend id='3hWhS'></legend><bdo id='3hWhS'><pre id='3hWhS'><center id='3hWhS'></center></pre></bdo></b><th id='3hWhS'></th></span></q></dt></tr></i><div id='3hWhS'><tfoot id='3hWhS'></tfoot><dl id='3hWhS'><fieldset id='3hWhS'></fieldset></dl></div>