Like the telephony call detection using phoneStateListener , I want to detect the call from Skype in android. Is there any listener for Skype like for telephony call. Please suggest some way.
Asked
Active
Viewed 3,126 times
7
-
its an independent app and uses internet calling, so i guess they might have not kept any open events for handling. – Neji Apr 07 '14 at 05:55
-
If Skype doesn't give you any documentation, that's gonna be hard, see impossible. One thing you could look at is the logs of skype. If you notice an intent that is broadcasted via Android, then this could possibly used as hook. – Snicolas Apr 07 '14 at 05:57
-
@Snicolas Thanks I will look for this. Is there any way through socket to detect the Skype call. – Ajit Apr 07 '14 at 06:06
-
@Ajit, I don't think so. – Snicolas Apr 07 '14 at 06:20
-
@Snicolas Ok. Could you please answer this question http://stackoverflow.com/questions/22833548/differenciate-the-text-of-voice-in-android – Ajit Apr 07 '14 at 06:23
-
@Ajit, no idea about that additional question. – Snicolas Apr 07 '14 at 14:16
2 Answers
5
Thanks to my friend Shazli, There is a reliable workaround to solve this issue.
Whenever skype call gets connected it puts up a notification and on ending the call it removes the notification. NotificationListenerService can be used to detect the skype notification.
Add below lines in the manifest file.
<service android:name=".SkypeNotificationListenerService"
android:label="@string/app_name"
android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE">
<intent-filter>
<action android:name="android.service.notification.NotificationListenerService" />
</intent-filter>
</service>
Create a service to listen the notifications.
public class SkypeNotificationListenerService extends NotificationListenerService {
private boolean mSkypeConnected;
private static final String TAG = "NM";
public SkypeNotificationListenerService() {
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
return super.onStartCommand(intent, flags, startId);
}
@Override
public void onCreate() {
super.onCreate();
Log.d(TAG, "Service created");
IntentFilter filter = new IntentFilter();
filter.addAction("com.example.NOTIFICATION_LISTENER");
LocalBroadcastManager.getInstance(this)
.registerReceiver(nlServiceReceiver, filter);
}
@Override
public void onDestroy() {
super.onDestroy();
LocalBroadcastManager.getInstance(this)
.unregisterReceiver(nlServiceReceiver);
}
@Override
public IBinder onBind(Intent intent) {
return super.onBind(intent);
}
@Override
public void onNotificationPosted(StatusBarNotification sbn) {
super.onNotificationPosted(sbn);
String packageName = sbn.getPackageName();
Log.d(TAG, "onNotificationPosted " + packageName);
if(packageName != null && packageName.equals("com.skype.raider")) {
Intent intent = new Intent("com.example.NOTIFICATION_LISTENER");
intent.putExtra("connected", true);
LocalBroadcastManager.getInstance(this).sendBroadcast(intent);
}
}
@Override
public void onNotificationRemoved(StatusBarNotification sbn) {
super.onNotificationRemoved(sbn);
String packageName = sbn.getPackageName();
Log.d(TAG, "onNotificationRemoved " + packageName);
if(packageName != null && packageName.equals("com.skype.raider")) {
Intent intent = new Intent("com.example.NOTIFICATION_LISTENER");
intent.putExtra("connected", false);
LocalBroadcastManager.getInstance(this).sendBroadcast(intent);
}
}
@Override
public StatusBarNotification[] getActiveNotifications() {
return super.getActiveNotifications();
}
BroadcastReceiver nlServiceReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if(intent != null) {
boolean connected = intent.getBooleanExtra("connected", false);
Intent skypeIntent;
skypeIntent = new Intent(Constants.SKYPE_CONNECTED);
if(connected && !mSkypeConnected) {
mSkypeConnected = true;
skypeIntent.putExtra("connected", true);
} else if(!connected) {
mSkypeConnected = false;
Log.d(TAG, "send broadcast disconnected");
skypeIntent.putExtra("connected", false);
}
sendStickyBroadcast(skypeIntent);
}
}
};

Amit
- 3,422
- 3
- 28
- 39
-
2This flags any notification from Skype as active call, Skype might put up notifications for other reasons, such as chat messages. You would probably need to do some heuristic on the actual notification contents for this to be reliable (until Skype changes those details). – Cumbayah Jan 26 '16 at 09:31
-
-
Just a string which defines the intent action. In my case it's com.example.SKYPE_CONNECTED"; – Amit Dec 09 '16 at 07:09
-2
No bro their are no buddy listener for skype like telephony call or other way use skype for windows or android tools better work hard layer and yard way to posstion on the diffrent topics.