一个安卓项目运行在5.0的设备上就会报错

移动开发 码拜 9年前 (2015-11-15) 848次浏览
以下是错误日志
一个安卓项目运行在5.0的设备上就会报错
以下是提示错误的类的代码

/*
 * Copyright (c) 2013. wyouflf (wyouflf@gmail.com)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.c1tech.dress.bitmap.xutils.util.core;
import java.util.concurrent.ConcurrentHashMap;
/**
 * Author: wyouflf
 * Date: 13-8-1
 * Time: 上午11:25
 */
public class KeyExpiryMap<K, V> extends ConcurrentHashMap<K, Long> {
    /**
     *
     */
    private static final long serialVersionUID = 1L;
    private static final int DEFAULT_CONCURRENCY_LEVEL = 16;
    public KeyExpiryMap(int initialCapacity, float loadFactor, int concurrencyLevel) {
        super(initialCapacity, loadFactor, concurrencyLevel);
    }
    public KeyExpiryMap(int initialCapacity, float loadFactor) {
        super(initialCapacity, loadFactor, DEFAULT_CONCURRENCY_LEVEL);
    }
    public KeyExpiryMap(int initialCapacity) {
        super(initialCapacity);
    }
    public KeyExpiryMap() {
        super();
    }
    @Override
    public synchronized Long get(Object key) {
        if (this.containsKey(key)) {
            return super.get(key);
        } else {
            return null;
        }
    }
    @Override
    public synchronized Long put(K key, Long expiryTimestamp) {
        if (this.containsKey(key)) {
            this.remove(key);
        }
        return super.put(key, expiryTimestamp);
    }
    @Override
    public synchronized boolean containsKey(Object key) {
        boolean result = false;
        if (super.containsKey(key)) {
            if (System.currentTimeMillis() < super.get(key)) {
                result = true;
            } else {
                this.remove(key);
            }
        }
        return result;
    }
    @Override
    public synchronized Long remove(Object key) {
        return super.remove(key);
    }
    @Override
    public synchronized void clear() {
        super.clear();
    }
}
解决方案:20分
你用的是XUtils的BitmapUtils加载图片了吧,建议用其他的图片加载库。必须用的话设置缓存,不用缓存,用硬件缓存,加如下代码

bitmapUtils.configDiskCacheEnabled(true);
bitmapUtils.configMemoryCacheEnabled(false);
解决方案:20分
从log上看,是原因是xUtils的问题导致的。
不建议使用xutils,里面很多坑,你可以把图片加载相关先屏蔽掉,看看能否还有错误,假如是原因是这个问题,在想办法看看是修改一下源码,还是使用其它的替代方案。

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明一个安卓项目运行在5.0的设备上就会报错
喜欢 (0)
[1034331897@qq.com]
分享 (0)