Call Detection for skype in android -
like telephony call detection using phonestatelistener , want detect call skype in android. there listener skype telephony call. please suggest way.
thanks friend shazli, there reliable workaround solve issue.
whenever skype call gets connected puts notification , on ending call removes notification. notificationlistenerservice can used detect skype notification.
add below lines in 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 service listen 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); } } };
Comments
Post a Comment