问题
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