【问题标题】:Call Detection for skype in androidandroid中Skype的呼叫检测
【发布时间】:2023-03-24 06:20:02
【问题描述】:

就像使用 phoneStateListener 进行电话呼叫检测一样,我想在 android 中检测来自 Skype 的呼叫。是否有像电话呼叫一样的 Skype 监听器。 请提出一些建议。

【问题讨论】:

  • 它是一个独立的应用程序并使用互联网通话,所以我猜他们可能没有保留任何开放的事件来处理。
  • 如果 Skype 没有给你任何文档,那将很难,看起来不可能。您可以查看的一件事是Skype的日志。如果您注意到通过 Android 广播的意图,那么这可能会用作钩子。
  • @Snicolas 谢谢我会找这个。有没有办法通过socket检测Skype通话。
  • @Ajit,我不这么认为。
  • @Snicolas 好的。你能回答这个问题吗stackoverflow.com/questions/22833548/…

标签: android skype


【解决方案1】:

感谢我的朋友 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>

创建一个服务来监听通知。

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);
        }
    }
};

【讨论】:

  • 这会将来自 Skype 的任何通知标记为活动呼叫,Skype 可能会出于其他原因发布通知,例如聊天消息。您可能需要对实际的通知内容进行一些启发式测试,以使其可靠(直到 Skype 更改这些详细信息)。
  • 什么是 Constants.SKYPE_CONNECTED?
  • 只是一个定义意图动作的字符串。就我而言,它是 com.example.SKYPE_CONNECTED";
【解决方案2】:

不,兄弟,他们不是 Skype 的好友监听器,例如电话呼叫或其他方式使用 Skype for windows 或 android 工具更好地工作层和院子的方式来发布不同的主题。

【讨论】:

  • 你在这里想说什么?
猜你喜欢
  • 2014-06-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-05-29
  • 2021-10-18
  • 1970-01-01
相关资源
最近更新 更多