首页 > 解决方案 > Android 工作简介:android.intent.action.DATA_SMS_RECEIVED 从未被解雇

问题描述

我正在开发一个通过 SMS(实际上是数据 SMS)与后端通信的应用程序。

发送和接收 SMS 在常规设置中完美运行,但是我们的一位用户启用了 Android工作配置文件,并且该应用程序安装在工作配置文件中。

现在应用程序没有收到 DATA_SMS_RECEIVED 意图。我试图找到有关此的任何文档,但没有找到。为了使 DATA_SMS_RECEIVED 在工作资料上工作,我需要做些什么特别的事情吗?

这是相关的清单声明:

<receiver android:name=".broadcastreceiver.SmsReceived" android:exported="true" >
    <intent-filter>
        <action android:name="android.intent.action.DATA_SMS_RECEIVED" />
        <data android:scheme="sms" />
        <data android:port="1234" />
    </intent-filter>
</receiver>

这是来自 BroadcastReceiver 的相关代码

public class SmsReceived extends BroadcastReceiver{
    private static final String DATA_SMS_RECEIVED_ACTION = "android.intent.action.DATA_SMS_RECEIVED";

    @Override
    public void onReceive(Context context, Intent intent) {
        try{
            if(intent.getAction().equalsIgnoreCase(DATA_SMS_RECEIVED_ACTION)){
                //Code here is not executed when installed in work profile
            }
        }catch(Exception e){

        }
    }
}

请注意:这是一个内部应用程序,Android 的新短信限制不适用。

标签: androidbroadcastreceiversmsandroid-work-profile

解决方案


推荐阅读