java.lang.Class<...> has no zero argument constructor。registerReceiver(myBroadcastReceiver, filter)。

写在前面:确切的说,这是采过的坑,记录的日志。或许,至今还在坑中,而不自知……

出现问题的起因:自定义了一个广播,并发送广播。

然后在另一个Activity中接收广播。

在注册广播时:registerReceiver(myBroadcastReceiver, filter);黄标报错。

就像这样:

提示:

`myBroadcastReceiver` is missing `RECEIVER_EXPORTED` or `RECEIVER_NOT_EXPORTED` flag for unprotected \ broadcasts registered for BROADCAST_ACTION

——必须把这个黄标解决掉!!!=非著名.又菜.又爱玩.业余程序员

我听说这个黄标是因为在manifest中没有注册的原因引起的。

于是跑到里面去注册,一开始,我是写成这样:

很明显,这有错误。我很快意识到,这个必须输入一个完整路径,也许能解决这个问题。

但我点了很久,于是,换了个方式报错:

直到我在Fragment中,将

 private class MyBroadcastReceiver extends BroadcastReceiver {       

        @Override
        public void onReceive(Context context, Intent intent) {
            //My Code
        }
    }

改成:

 public class MyBroadcastReceiver extends BroadcastReceiver {        

        @Override
        public void onReceive(Context context, Intent intent) {
           //My Code
        }
    }

终于可以点出来了:

随后,运行——接着报错:

java.lang.Class<...> has no zero argument constructor

于是,我又添加了零参构造函数:

 public class MyBroadcastReceiver extends BroadcastReceiver {
        private MyBroadcastReceiver() {
        }

        @Override
        public void onReceive(Context context, Intent intent) {
            //My Code
        }
    }

这里写成public和private我没有明显的感觉到有啥区别。因为我有多个Activity需要接收这个广播(在同一个地方发送,在n个地方接收),所以我选择了private。

随后,运行——接着报错、闪退:

java.lang.Class<...> has no zero argument constructor

一次偶然的机会,我在申明处和接收处写了不同的action,发现不报错了。于是,我写成了这样(至于为什么,还没有搞清,只是可以运行了):

但是在发送、接收处的action都写成

BROADCAST_ACTION

也就是,少了一部少(或者说不一样,一样就会报错)。

最后,解决黄标报错,是在new IntentFilter时,改为全局变量。(至于为什么,我也没有搞清。而且前面不能写private,写完又黄标报错……)

注意,这个action,与前面申明的名字不一样!

这样,就可以运行了……

——然而,这个时候并没有完。签名打包时,会报错。提示在build.gradle里添加

android {
    lint {
        baseline = file("lint-baseline.xml")
    }
}

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
dubbo.xsd 复制代码 <dubbo:service/> 服务配置,用于暴露一个服务,定义服务的元信息,一个服务可以用多个协议暴露,一个服务也可以注册到多个注册中心。 eg、<dubbo:service ref="demoService" interface="com.unj.dubbotest.provider.DemoService" /> <dubbo:reference/> 引用服务配置,用于创建一个远程服务代理,一个引用可以指向多个注册中心。 eg、<dubbo:reference id="demoService" interface="com.unj.dubbotest.provider.DemoService" /> <dubbo:protocol/> 协议配置,用于配置提供服务的协议信息,协议由提供方指定,消费方被动接受。 eg、<dubbo:protocol name="dubbo" port="20880" /> <dubbo:application/> 应用配置,用于配置当前应用信息,不管该应用是提供者还是消费者。 eg、<dubbo:application name="xixi_provider" /> <dubbo:application name="hehe_consumer" /> <dubbo:module/> 模块配置,用于配置当前模块信息,可选。 <dubbo:registry/> 注册中心配置,用于配置连接注册中心相关信息。 eg、<dubbo:registry address="zookeeper://192.168.2.249:2181" /> <dubbo:monitor/> 监控中心配置,用于配置连接监控中心相关信息,可选。 <dubbo:provider/> 提供方的缺省值,当ProtocolConfig和ServiceConfig某属性没有配置时,采用此缺省值,可选。 <dubbo:consumer/> 消费方缺省配置,当ReferenceConfig某属性没有配置时,采用此缺省值,可选。 <dubbo:method/> 方法配置,用于ServiceConfig和ReferenceConfig指定方法级的配置信息。 <dubbo:argument/> 用于指定方法参数配置。
---------ChromeDriver 75.0.3770.140 (2019-07-12)--------- Supports Chrome version 75 Resolved issue 3007: ChromeDriver 75 - Running Javascript kills driver [Pri-1] Resolved issue 2943: goog:chromeOptions.w3c=false doesn't work for POST request with empty body [Pri-1] Resolved issue 2975: Webdriver Actions for keys (CONTROL, SHIFT etc..) not working in ChromeDriver 75.0.3770.8 [Pri-2] Resolved issue 2947: No W3C compliant endpoints for retrieving logs [Pri-2] Resolved issue 2622: Clear Element command raises blur event twice [Pri-2] Resolved issue 2803: Capability name loggingPrefs is not spec compliant [Pri-2] Resolved issue 2536: Make standards mode (goog:chromeOptions.w3c:true) the default [Pri-2] Resolved issue 2836: Error handling in W3C mode [Pri-2] Resolved issue 2414: Creating cookies without leading dot in the domain results in host-only cookies [Pri-2] Resolved issue 2796: ChromeDriver should allow null for script timeout [Pri-2] Resolved issue 2721: Element Send Keys to file input with 'multiple' attribute should append file list [Pri-3] Resolved issue 2850: Get Active Element should return "no such element" error when no active element exists [Pri-3] Resolved issue 2851: Navigate to malformed URL should raise "invalid argument" error [Pri-3] Resolved issue 2857: ChromeDriver returns wrong HTTP status code when invalid session id is received [Pri-3] Resolved issue 2719: When input parameter is missing or malformed, ChromeDriver response is not spec compliant [Pri-3] Resolved issue 2746: Execute Script does not handle line-oriented JavaScript comment [Pri-3]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

白云LDC

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值