How to detect when Facebook messenger is bubble is opend?

可紊 提交于 2021-02-08 03:59:24

问题


Facebook uses a service to push the messenger bubble on android - something like the follows: http://www.piwai.info/chatheads-basics/

I want to detect when the bubble is opened / closed

I've started investigating the following options -

  • Listen (By pulling) to the running services - I found out there are 4 services when the messenger is shown and 2 when it's killed. I want to know when the messenger bubble is close so it doesn't help me.

  • Listen to the notifications - I know when it's removed completely (when user drags it to the 'X' area) - also didn't help.

I'm looking for a hack to know when does the Facebook bubble is opened and when does it closes.


回答1:


By open\closed did you mean that the chat bubble remains on screen and the chat window is opened\closed, or that the bubble is either visible or invisible? In case of the latter:

Inspecting the AndroidManifest.xml we can see the following:

<receiver android:name="com.facebook.orca.chatheads.service.ChatHeadsServiceBroadcastReceiver"
          android:permission="com.facebook.permission.prod.FB_APP_COMMUNICATION">
    <intent-filter android:priority="499">
        <action android:name="com.facebook.orca.chatheads.ACTION_SHOW_CHATHEADS"/>
        <action android:name="com.facebook.orca.chatheads.ACTION_HIDE_CHATHEADS"/>
        <action android:name="com.facebook.orca.chatheads.ACTION_SET_CHATHEADS_POLICY"/>
    </intent-filter>
</receiver>

You could possibly try to intercept these broadcasts inside a service of your own and track the opening\closing of the bubbles somehow.


(Disclosure: I never tried anything like that myself, and would be happy to revise\delete this answer if this suggestion proves impractical)




回答2:


I am afraid you cannot do that.

To do that Facebook app should use one of the public Android APIs like Broadcasts or even Notifications. But they are not using any of them.

When user close the bubble, it just close internally. You cannot access it.

You may access it using something called xposed framework for rooted devices.



来源:https://stackoverflow.com/questions/27632995/how-to-detect-when-facebook-messenger-is-bubble-is-opend

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!