android中skype的呼叫检测
就像使用phoneStateListener进行电话呼叫检测一样,我希望在android中检测来自Skype的呼叫。是否有类似于电话通话的Skype侦听器。android中skype的呼叫检测,android,skype,Android,Skype,就像使用phoneStateListener进行电话呼叫检测一样,我希望在android中检测来自Skype的呼叫。是否有类似于电话通话的Skype侦听器。 请提出一些建议。没有兄弟,他们没有skype的好友侦听器,比如电话或其他方式使用skype for windows或android工具,更好地努力工作,在不同的主题上以一层一层的方式进行定位。感谢我的朋友Shazli,有一个可靠的解决方法来解决这个问题 无论何时skype呼叫连接,它都会发出通知,并在结束呼叫时删除通知。Notificati
请提出一些建议。没有兄弟,他们没有skype的好友侦听器,比如电话或其他方式使用skype for windows或android工具,更好地努力工作,在不同的主题上以一层一层的方式进行定位。感谢我的朋友Shazli,有一个可靠的解决方法来解决这个问题 无论何时skype呼叫连接,它都会发出通知,并在结束呼叫时删除通知。NotificationListenerService可用于检测skype通知 在清单文件中添加以下行
<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>
这是一个独立的应用程序,使用互联网呼叫,所以我想他们可能没有保留任何开放事件来处理。如果Skype没有给你任何文档,那将很难,看不到不可能。你可以看看skype的日志。如果你注意到一个通过安卓系统广播的意图,那么这个可能会被用作钩子。@Snicolas谢谢,我会寻找这个。有没有办法通过套接字来检测Skype呼叫。@Ajit,我不这么认为。@Snicolas Ok。您能回答这个问题吗?这个问题将来自Skype的任何通知标记为活动呼叫,Skype可能会出于其他原因发出通知,例如聊天信息。您可能需要对实际的通知内容进行一些启发式操作,以使其可靠(直到Skype更改这些详细信息)。什么是常量。Skype_已连接?只是一个定义意图操作的字符串。在我的例子中是com.example.SKYPE_CONNECTED“你在这里想说什么?
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);
}
}
};