国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > Android > 正文

Android開發中那些需要注意的坑

2019-12-12 06:33:56
字體:
來源:轉載
供稿:網友

這個是看知乎的時候發現的一個問題,感覺挺有意思,就將自己遇到的坑記錄下來。

1、Andorid L theme colorPrimary 不能使用帶有alpha的顏色值,否則會有異常拋出, 直接判斷了是否alpha是否等于0或者255,其他都會異常

@Overrideprotected 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 activityif (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花屏,由于過度繪制導致,關閉硬件加速, 尤其是使用webview后,可能會有大概率出現。

3、華為手機被KILL一系列問題

用戶可以設置某個應用是否后臺保護,按照華為的功能說明,理解為,如果不保護,那鎖屏后程序將無法保持運行,也就是進程可能被KILL

新安裝應用后,華為會給出選項,是否保持,這個默認選項上存在問題,有的應用默認不允許,有的應用默認就允許。

關于耗電高被KILL問題。

關于鎖屏后網絡被切斷問題。鎖屏就算保護,而網絡或者SOCKET也可能被主動切斷。

華為自己給出了BASTET系統解決方案,具體不展開。
4、相同顏色值在全局是同一份,如果對其改變獲取后的colorDrawable值,會導致其它所有使用的地方都改變,可以采用mutable避免。 這個其實不能算作坑,是自己代碼沒有看仔細。

5、華為p8手機,如果service與ui不在同一進程,service中監控網絡的BroadcastReciver 會收不到網絡連接的廣播,但是能收到斷開的廣播,這個應該也是華為自己的優化,但是ui中的連接與斷開都能收到廣播。

6: Android 在4.4后更新了webview內核,在5.0前在webview中,不用的域可以讀取其它域設置的cookie,但是在5.0開始,系統默認值改為了false。這樣會導致之前以前采用舊方法的不能獲取到。(其實在我看來,確實不應該跨域來讀取cookie,多不安全)

  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {      CookieManager.getInstance().setAcceptThirdPartyCookies(mWebView, true);    }

以上就是本文的全部內容,希望對大家的學習有所幫助。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 西峡县| 迭部县| 威信县| 林芝县| 正镶白旗| 饶阳县| 米易县| 恭城| 繁昌县| 蓝田县| 平舆县| 年辖:市辖区| 安徽省| 安康市| 都江堰市| 大庆市| 香港 | 唐河县| 喜德县| 中山市| 新密市| 新干县| 彝良县| 清原| 泌阳县| 丹凤县| 股票| 海安县| 突泉县| 太白县| 财经| 遵义县| 乐陵市| 平阴县| 盐城市| 崇文区| 左权县| 微山县| 龙陵县| 昌图县| 郎溪县|