I am making an emoticon app like Emojidom https://play.google.com/store/apps/details?id=com.plantpurple.emojidom
When i try to access my app from WeChat, i cannot do that.. but i can see that emojidom app is accessible from WeChat. I have added all the necessary premissions in my app for picking up images but still it doesn't show up in wechat.. It shows up in whatsapp though. I want it like this.. see screenshot
In the top of this chat window in wechat, we can see the emojidom icon, but i cant get mine to appear there... how to do so... any idea? I think i need to write a service to monitor when wechat comes in foreground. Any idea how to write such a service which monitors when a specific application comes to foreground?
First of all, i dont know if you are doing it this way, but what Emojidom does here is not including an icon in the action bar, instead, it draws itself on top of your apps, as a floating icon. A well known example of this, is the Facebook Messenger App, that draws icons for active chats floating in the screen. To achieve this, you can follow this tutorial: http://www.piwai.info/chatheads-basics/
Second, Emojidom only draws itself when a eligible app is in the foreground. We are lucky, since we have a method to detect what app is in the foreground.
for this, we create a method like this:
If you check the
RunningAppProcessInfo
class, it is easy to know the name of the package, since you can easily check all the package names (for instannce in the play website) you can prepare a list of packages of the apps you want to consider, and put the list in a variable in your app.Third. I dont know in wechat, but in whatsapp, the icon only is displayed when a chat is open (i.e. you cannot see it in the list of chats or configuration screens).
For this, you can check what activity is actually running in the active app, we can use this method, that will check if the package name of any of the running tasks, is the same of the foreground app, and returning the info
Take a look at the ComponentName class to get the information you need.
To know what activity represents every screen of every app, you can try to find out on google, or make a simple app to list all the running task on your own mobile, and run all the apps that you want to check