Check if app is open during a GCM onMessage event?

后端 未结 4 1203
长发绾君心
长发绾君心 2020-12-16 02:45

I am wondering how to check if my application is open and currently visible to the user when receiving an onMessage() from GCM. At first, I was just using my ow

4条回答
  •  抹茶落季
    2020-12-16 02:55

    Use SharedPreferences saving the boolean isVisible, and when you get the value from the preference you can add a default value.

    SharedPreferences settings = context.getSharedPreferences("NAME_XXX", Activity.MODE_PRIVATE);
    settings.getBoolean("visible", false);
    

提交回复
热议问题