package com.hdl.hdllinphonesdk.receiver; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.text.TextUtils; /** * Created by panlili on 2023/10/11 * description: */ public class CallBroadcastReceiver extends BroadcastReceiver { private static CallBroadcastListener listener; public static final String CALL_RECEIVED_ACTION = "com.hdl.homepro.call.action"; @Override public void onReceive(Context context, Intent intent) { if (intent.getAction().equals(CALL_RECEIVED_ACTION)) { String callFrom = intent.getStringExtra("callFrom"); if (!TextUtils.isEmpty(callFrom)) { if (listener != null) { listener.onReceived(callFrom); } } } } //回调接口 public interface CallBroadcastListener { public void onReceived(String callFrom); } public void setOnReceivedCallBroadcastListener(CallBroadcastListener listener) { this.listener = listener; } }