android 单元测试 注册广播接收器

来源:互联网 发布:淘宝新品上架2小时内刷 编辑:程序博客网 时间:2024/05/21 08:56
在单元测试里面注册广播接收器失败
    public void setUp() throws Exception {
        MApplication application = MApplication.getInstance();
        IntentFilter intentFilter = new IntentFilter();
        intentFilter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED);
        //此处intent为null
        Intent intent = application.registerReceiver(new MBluetoothBroadcastReceiver(),intentFilter);
        mBluetoothAdapter = MBluetoothAdapter.getDefaultAdapter();
    }

0 0