如何在颤振中获取即将到来的电话号码

时间:2021-06-25 18:56:16

标签: flutter dart broadcastreceiver incoming-call

你好,我需要知道如何获取传入的电话号码并检查它是否存在于我的数据库中我试图与鸽子一起工作但它没有用有人可以给出我应该遵循的步骤.

我试过了,没用:

public class ServiceReceiver extends BroadcastReceiver {

@Override
public void onReceive(final Context context, Intent intent) {
    TelephonyManager telephony = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
    telephony.listen(new PhoneStateListener(){
        @Override
        public void onCallStateChanged(int state, String incomingNumber) {
            super.onCallStateChanged(state, incomingNumber);
            System.out.println("incomingNumber : "+incomingNumber);
        }
    },PhoneStateListener.LISTEN_CALL_STATE);
}

0 个答案:

没有答案