編輯:關於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花屏,由於過度繪制導致,關閉硬件加速, 尤其是使用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);
}
以上就是本文的全部內容,希望對大家的學習有所幫助。
Android基礎入門教程——7.5.6 WebView處理網頁返回的錯誤碼信息
本節引言: 嘿嘿,假如你們公司是做HTML5端的移動APP的,就是通過WebView來顯示網頁的,假如你訪問的網頁 不存在,或者其他錯誤,報404,401,4
Android MotionEvent詳解
我們已經了解了android觸摸事件傳遞機制,接著我們再來研究一下與觸摸事件傳遞相關的幾個比較重要的類,比如MotionEvent。我們今天就來詳細說明一下這個類的各方面
Android 圖像處理(一) : Shader
?之前一段時間,我都在研究Android自定義View的相關知識,隨著逐漸的深入,漸漸了解到了一些Android圖像處理的知識,主要是Bitmap,Canvas,Shad
android tv gridview焦點放大效果
在tv上開發gridview有焦點放大這個效果還是很普遍的做法,今天就講下這個實現方案,當然要實現這個效果有很多種,我這裡只是講其中的一種實現方案,也是比較簡單而且容易看