Refreshing activity on receiving gcm push notification

后端 未结 7 1351
自闭症患者
自闭症患者 2020-11-29 16:45

Update: GCM is deprecated, use FCM

How to refresh activity on receiving gcm push notification<

7条回答
  •  忘掉有多难
    2020-11-29 17:34

    I'm assuming your GCMBroadcastReceiver is in it's own .java file?

    As far as refreshing an activity, I would also like to know the answer to that question.

    But for knowing if a particular activity is active or not, meaning on screen just add a boolean (call it something like "active") and set it to true in your activity's onResume() event, and to false in the onPause() event:

    protected void onResume()
    {
        super.onResume();
    
        active = true;;
    }
    
    protected void onPause()
    {
        super.onPause();
    
        active = false;
    }
    

    Your active variable would be a boolean which is global or static. This way you know if a particular activity is in "front".

    Hope that helps a bit.

提交回复
热议问题