panlili2024
2024-11-13 848cbfebefab08cc49b0285155edb84463aed862
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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;
    }
}