android - 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 的新短信限制不适用。
解决方案
推荐阅读
- excel - 从 Excel 工作簿生成 Word 财务报表
- java - 如何按依赖顺序正确加载项目的类?
- javascript - 只显示一个输出
- android - 按钮展开动画出现在其他元素下方
- rest - API 或客户端-服务器系统被视为 RESTFul 的基本要求是什么?
- java - 如果是@Transactional,删除方法不会影响数据库
- java - 如何在BottomNavigationView的片段JAVA类中使用谷歌登录方法获取用户详细信息?
- javascript - 我正在尝试使用钩子来管理 Context.Provider 的状态
- protocol-buffers - 未找到自定义原始包装器的 ScalaPB TypeMapper
- ios - CollectionView 单元格未显示在屏幕上