开发者论坛

 找回密码
 注册 (请使用非IE浏览器)
查看: 2023|回复: 0

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

[复制链接]

0

精华

0

贡献

1

赞扬

帖子
15
软币
200
在线时间
10 小时
注册时间
2016-9-23
发表于 2016-9-23 11:46:18 | 显示全部楼层 |阅读模式

1Andorid 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;
}
2android 5.0花屏,由于过度绘制导致,关闭硬件加速
3:华为的受保护应用问题,华为有自己的一套连接机制,时间一长就把网络给切断掉
4:相同颜色值在全局是同一份,如果对其改变获取后的colorDrawable值,会导致其它所有使用的地方都改变,可以采用mutable避免
/////// ps 再来补一个坑
华为p8手机,如果serviceui不在同一进程,service中监控网络的BroadcastReciver 收不到网络连上的广播,但是能收到断开的广播。
建议做手游测试或者App测试时使用第三方测试平台,比如像Testbird自动化测试平台(现在注册送免费调试时间)之类的,方便快捷,且结论更准确。

回复

使用道具 举报

Archiver|手机版|小黑屋|开发者网 ( 苏ICP备08004430号-2 )
版权所有:南京韵文教育信息咨询有限公司

GMT+8, 2024-4-26 06:25

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表