Android Whatsapp Call Start Broadcast Receiver

I am working on an application that should receive some kind of notification / Receiver when starting a WhatsApp call (both at the end of the caller and at the recipient) or ends. Is it possible to receive incoming / outgoing information about WhatsApp calls in my application?

I tried using the accessibility service

Using the package name as " com.whatsapp ", I cannot fulfill my requirement. Will someone suggest me what to do? Or can it really be done? IF yes, then please explain how.

+6
source share
2 answers

I tried this and I can grab the whatsapp button's call button and click the close button. Below is the simple AccessibilityService I used, and it is no different from the example available on the Android Developers website.

 public class MyAccessibilityService extends AccessibilityService { @Override protected void onServiceConnected() { AccessibilityServiceInfo info = new AccessibilityServiceInfo(); // Set the type of events that this service wants to listen to. Others // won't be passed to this service. info.eventTypes = AccessibilityEvent.TYPE_VIEW_CLICKED | AccessibilityEvent.TYPE_VIEW_FOCUSED; // If you only want this service to work with specific applications, set their // package names here. Otherwise, when the service is activated, it will listen // to events from all applications. info.packageNames = new String[] {"com.whatsapp","com.android.calendar"}; // Set the type of feedback your service will provide. info.feedbackType = AccessibilityServiceInfo.FEEDBACK_SPOKEN; // Default services are invoked only if no package-specific ones are present // for the type of AccessibilityEvent generated. This service *is* // application-specific, so the flag isn't necessary. If this was a // general-purpose service, it would be worth considering setting the // DEFAULT flag. // info.flags = AccessibilityServiceInfo.DEFAULT; info.notificationTimeout = 100; this.setServiceInfo(info); } @Override public void onAccessibilityEvent(AccessibilityEvent event) { final int eventType = event.getEventType(); String eventText = null; switch(eventType) { case AccessibilityEvent.TYPE_VIEW_CLICKED: eventText = "Focused: "; break; case AccessibilityEvent.TYPE_VIEW_FOCUSED: eventText = "Focused: "; break; } //eventText = eventText + event.getContentDescription(); // Do something nifty with this text, like speak the composed string // back to the user. Toast.makeText(getApplicationContext(),""+eventText +" --- "+event.getContentDescription(),Toast.LENGTH_LONG).show(); } @Override public void onInterrupt() { } 

}

In the above code, I showed a message with a toast and a trick for drawable, we will provide a contentDescription that can be used by the system in the "Talkback" accessibility mode. Hope this helps !!!

+3
source

Allow the request .... The accessibility service will help you get a notification that when you receive notifications against your required package name. for example, "com.whatsapp".

Now it’s good that you can parse the notification message over time with Android 4.2 in the Accessibility Service with minimal effort. Unfortunately for you, there was a github project that definitely did the desired thing, but is currently unavailable.

+1
source

All Articles