Ошибка приложения на версиях ниже Nougat [duplicate]

Вы можете использовать эту пользовательскую библиотеку (написанную с помощью Promise) для выполнения удаленного вызова.

function $http(apiConfig) {
    return new Promise(function (resolve, reject) {
        var client = new XMLHttpRequest();
        client.open(apiConfig.method, apiConfig.url);
        client.send();
        client.onload = function () {
            if (this.status >= 200 && this.status < 300) {
                // Performs the function "resolve" when this.status is equal to 2xx.
                // Your logic here.
                resolve(this.response);
            }
            else {
                // Performs the function "reject" when this.status is different than 2xx.
                reject(this.statusText);
            }
        };
        client.onerror = function () {
            reject(this.statusText);
        };
    });
}

Пример простого использования:

$http({
    method: 'get',
    url: 'google.com'
}).then(function(response) {
    console.log(response);
}, function(error) {
    console.log(error)
});
19
задан Jack 20 March 2015 в 13:43
поделиться

3 ответа

Вы не можете использовать альфа в основном цвете.

Изменить:

<item name="colorPrimaryDark">#4DFF9800</item>
<item name="colorPrimary">#4D607D8B</item>

To

<item name="colorPrimaryDark">#FF9800</item>
<item name="colorPrimary">#607D8B</item>

для api 21 в файле res/values-v21/style.xml

57
ответ дан Konrad Krakowiak 24 August 2018 в 09:11
поделиться

@ Konrad Krakowiak прав. Вы можете увидеть исходный код android.app.ActivityManager # TaskDescription.

/**
    * 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;
    }
1
ответ дан Jimson 24 August 2018 в 09:11
поделиться

Простое решение проблемы заключается в том, чтобы удалить непрозрачный, примененный к основному цвету в colors.xml

Когда непрозрачный применяется к основному цвету, цветовой код выглядит так: # aca688ff, где он например, «# F50057» (буквенно-цифровой код букв без непрозрачности).

Надеемся, что вышеупомянутое решение поможет вам устранить проблему.

0
ответ дан Shivaramakrishna Agapu 24 August 2018 в 09:11
поделиться
Другие вопросы по тегам:

Похожие вопросы: