• Andriod開發中,有哪些坑需要注意?

    1
    Android C/C++ Andriod Go ico 11631 次瀏覽
    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避免。
    5:華為p8手機,如果service與ui不在同一進程,service中監控網絡的BroadcastReciver 收不到網絡連上的廣播,但是能收到斷開的廣播。
    6:建議做手游或者app測試時使用第三方測試平臺,比如像Testbird云測平臺(現在注冊送免費調試時間)之類的,方便快捷,且結論更準確。

    相似問題

    相關經驗

    相關資訊

    相關文檔

  • sesese色