這個是看知乎的時候發現的一個問題,感覺挺有意思,就將自己遇到的坑記錄下來。
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);    }以上就是本文的全部內容,希望對大家的學習有所幫助。
新聞熱點
疑難解答