资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

android实现常驻通知栏报的案例分析-创新互联

创新互联www.cdcxhl.cn八线动态BGP香港云服务器提供商,新人活动买多久送多久,划算不套路!

温岭ssl适用于网站、小程序/APP、API接口等需要进行数据传输应用场景,ssl证书未来市场广阔!成为成都创新互联的ssl证书销售渠道,可以享受市场价格4-6折优惠!如果有意向欢迎电话联系或者加微信:028-86922220(备注:SSL证书合作)期待与您的合作!

小编给大家分享一下android实现常驻通知栏报的案例分析,希望大家阅读完这篇文章后大所收获,下面让我们一起去探讨方法吧!

实现常驻通知栏时遇到的问题:

无论如何就是不显示通知,查看日志发现貌似报错了:

2020-06-28 14:11:34.923 6387-6387/xxx E/CrashReport: android.app.RemoteServiceException: Bad notification posted from package xxx: Couldn't inflate contentViewsandroid.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class android.support.constraint.ConstraintLayout
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1944)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:192)
        at android.app.ActivityThread.main(ActivityThread.java:6815)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:549)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:818)

说的是布局报错,所使用的布局如下:

android实现常驻通知栏报的案例分析

 根据报错信息来看,就是这个

android.support.constraint.ConstraintLayout

的问题了。

然后将布局的根view修改为RelativeLayout。

运行,报错,,,,纳尼?

2020-06-28 14:24:02.622 11436-11436/xxx E/CrashReport: android.app.RemoteServiceException: Bad notification posted from package xxx: Couldn't inflate contentViewsandroid.view.InflateException: Binary XML file line #2: Binary XML file line #2: You must supply a layout_height attribute.
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1944)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:192)
        at android.app.ActivityThread.main(ActivityThread.java:6815)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:549)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:818)

虽然继续报错,但是发现跟第一次报的错不同了,说明第一个报错问题解决。

那么来细看第二个报错信息:

Binary XML file line #2: You must supply a layout_height attribute.

看信息是说布局中缺少layout_height属性,但是确认布局中设置了这属性啊。。。

<?xml version="1.0" encoding="utf-8"?>

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

文章标题:android实现常驻通知栏报的案例分析-创新互联
文章转载:http://cdkjz.cn/article/ccphse.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

业务热线:400-028-6601 / 大客户专线   成都:13518219792   座机:028-86922220