- 博客(6)
- 资源 (10)
- 收藏
- 关注
原创 Android应用图标上的小红点Badge实现
Android应用图标上的小红点Badge实现为了增加APP的日活,在Android中有许多的应用仿苹果的在应用图标上显示小红点。当然有着一些手机ROM对小红点的支持,比如小米,三星等。我们下面看下如何实现:MainActivity:public class MainActivity extends AppCompatActivity { private Handler handler =
2016-12-28 21:55:19 23541 4
原创 Android电量和插拔电源状态广播监听
Android电量和插拔电源状态广播监听Android电量广播状态有3种,电量低,电量充满,电量发生改变。 Action是:Intent.ACTION_BATTERY_CHANGEIntent.ACTION_BATTERY_LOWIntent.ACTION_BATTERY_OKAYAndroid的插拔电源广播的Action是:Intent.ACTION_POWER_CONNECTEDInte
2016-12-20 22:02:13 17968 2
原创 Android打开WLAN开关的广播状态监听
Android打开WLAN开关的广播状态监听Android中WLAN的广播监听的是WLAN状态的改变 ,Action是WifiManager.WIFI_STATE_CHANGED_ACTION,WLAN的状态系统定义了5种,分别是WIFI_STATE_DISABLED WLAN已经关闭WIFI_STATE_DISABLING WLAN正在关闭WIFI_STATE_ENABLED
2016-12-20 22:00:23 4478
原创 Android锁屏与解锁广播状态监听
Android锁屏与解锁广播监听在Android开发中经常会碰到锁屏和解锁的需求,这里封装一个ScreenListener统一管理广播的注册和反注册,同时设置锁屏和解锁的回调监听。代码如下:public class ScreenListener { private Context mContext; private ScreenBroadcastReceiver receiver;
2016-12-20 21:59:16 12207 3
原创 静态工厂与策略模式的比较
静态工厂模式与策略模式的比较静态工厂模式:一般采用if…else语句或switch语句通过条件判断,并返回结果。这样写起来是比较方便的,适用于不复杂的类,但是该模式耦合程度比较高。策略模式:通过由实现类实现行为接口,在操作类中切换不同实现类的行为。这样写起来比较解耦,但是会导致类增多。适用于行为比较复杂的类。接下来看下实例代码:静态工厂模式:public class DateUtils { p
2016-12-06 12:57:44 875
原创 比较器Comparable与Comparator实践
比较器Comparable与Comparator实践Comparable:该比较器是用于对象的内部比较,比较的是属性。它的方法: public int compareTo(T o);Comparator:该比较器用于对象的外部比较,比较的是对象,一般这个比较的对象也实现了Comparable接口。Comparator的方法有多个,但一般我们只需要实现:int compare(T o1, T o2);
2016-12-06 12:56:13 469
Gradle for Android
2016-11-15
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人