Android 开发中,有哪些坑需要注意?

1:Andorid L theme colorPrimary 不能使用带有alpha的颜色值,否则会有异常抛出, 直接判断了是否alpha是否等于0或者255,其他都会异常

@Override

protected void onApplyThemeResource(Resources.Theme theme, int resid,

boolean first) {

if (mParent == null) {

super.onApplyThemeResource(theme, resid, first);

} else {

try {

theme.setTo(mParent.getTheme());

} catch (Exception e) {

// Empty

}

theme.applyStyle(resid, false);

}


// Get the primary color and update the TaskDescription for this activity

if (theme != null) {

TypedArray a = theme.obtainStyledAttributes(com.android.internal.R.styleable.Theme);

int colorPrimary = a.getColor(com.android.internal.R.styleable.Theme_colorPrimary, 0);

a.recycle();

if (colorPrimary != 0) {

ActivityManager.TaskDescription v = new ActivityManager.TaskDescription(null, null,

colorPrimary);

setTaskDescription(v);

}

}

}


/**

* Creates the TaskDescription to the specified values.

*

* @param label A label and description of the current state of this task.

* @param icon An icon that represents the current state of this task.

* @param colorPrimary A color to override the theme's primary color. This color must be opaque.

*/

public TaskDescription(String label, Bitmap icon, int colorPrimary) {

if ((colorPrimary != 0) && (Color.alpha(colorPrimary) != 255)) {

throw new RuntimeException("A TaskDescription's primary color should be opaque");

}


mLabel = label;

mIcon = icon;

mColorPrimary = colorPrimary;

}

2:android 5.0花屏,由于过度绘制导致,关闭硬件加速

3:华为的受保护应用问题,华为有自己的一套连接机制,时间一长就把网络给切断掉

4:相同颜色值在全局是同一份,如果对其改变获取后的colorDrawable值,会导致其它所有使用的地方都改变,可以采用mutable避免


/// ps 再来补一个坑

华为p8手机,如果service与ui不在同一进程,service中监控网络的BroadcastReciver 收不到网络连上的广播,但是能收到断开的广播。

建议做手游或者app测试时使用第三方测试平台,比如像Testbird云测平台之类的,方便快捷,且结论更准确


转载于:https://my.oschina.net/u/2613523/blog/603258

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值