关于显示Intent和隐式Intent

之前看了大神们写的博客,觉得自己也该有个好的记录习惯,从今天开始学习写博客,记录一下成长过程中的点点滴滴。


接手之前同事做的Android开发项目,想把项目做的更完美一些,所以关注了一些小细节,然后阅读了开发文档,疑惑得到了验证,特此标记一下。

在AndroidManifest.xml中,<service>标签前有个警告,写着"Exported service does not require permission",在百度上查找了一下,网友说android:exported属性默认为true,修改为false之后,警告消失了。

也是我闲来无事,阅读开发文档,在Intents and Intent Filters中介绍Intent类型时,有一段Caution:

Caution: To ensure your app is secure, always use an explicit intent when starting a Serviceand do not declare intent filters for your services. Using an implicit intent to start a service is a security hazard because you cannot be certain what service will respond to the intent, and the user cannot see which service starts. Beginning with Android 5.0 (API level 21), the system throws an exception if you call bindService() with an implicit intent.

原来之前遇到的警告,是因为service使用了隐式Intent,再到代码中去查找,果然都是通过action来启动的Service,果断将其修改为显示Intent来启动,警告解除了。

第一次写,也不会排版,希望以后能越写越好吧!

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值