Android系统中已经提供了CellBroadcastManager和CellBroadcastReceiver两个类来实现小区广播服务。但是,这两个类只支持3GPP格式的小区广播消息,不支持E-UTRAN格式。为了实现E-UTRAN格式的小区广播服务,可以使用以下方法:
示例代码:
public class EutranCellBroadcastReceiver extends CellBroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
byte[] data = intent.getByteArrayExtra("message");
// 解析E-UTRAN格式的小区广播消息,并发送通知
}
}
示例代码:
示例代码:
CellBroadcastManager cellBroadcastManager = (CellBroadcastManager) getSystemService(Context.CELL_BROADCAST_SERVICE); BroadcastReceiver cellBroadcastReceiver = new EutranCellBroadcastReceiver(); cellBroadcastManager.addCellBroadcastRange(0xffff, 0xffff); registerReceiver(cellBroadcastReceiver, new IntentFilter("android.provider.Telephony.SMS_CB_RECEIVED"));
通过以上步骤,就可以实现Android系统中E-UTRAN格式的小区广播服务。
上一篇:Android视图组问题
下一篇:android实现http服务器