异常处理异步线程队列java.lang.UnsupportedOperationException

时间:2011-03-03 18:18:18

标签: android

我在创建字符串数组时遇到问题,这只发生在2.1 android api 7级或更低级别,我需要在具有此配置的设备上安装应用程序,任何想法如何解决问题? 在源代码下面,屏幕上弹出的消息以及logcat的消息。

CODE:



private String[] fillPedidosName() {
    TipoPedidoDAO tipoDAO = null;
    try {
        tipoDAO = new TipoPedidoDAO();
        pedidosList = tipoDAO.selectAll();
            String[] temp = new String[pedidosList.size()];
        for (int i = 0; i < pedidosList.size(); i++) {
            if (pedidosList.get(i) != null) {
                temp[i] = pedidosList.get(i).getDescricao().toString();
            }
        }
        return temp;
    } catch (Exception ex) {
        MyLoger.logar(ex);
        return null;
    } finally {
        if (tipoDAO.getDB().isOpen()) {
            tipoDAO.closeConnection();
        }
    }
}

推迟调试的消息:

处理异步线程队列的异常 处理异步线程队列的异常 java.lang.UnsupportedOperationException

lOGCAT的消息:

03-03 17:57:57.124:ERROR / jdwp(1267):REQ:UNSUPPORTED(cmd = 2/11 dataLen = 8 id = 0x0012ba)

2 个答案:

答案 0 :(得分:0)

您可能没有使用支持get(int)的List。

尝试将List实现更改为ArrayList。创建列表时:

List myList = new ArrayList()

这可能发生在tipDAO.selectAll()内。

答案 1 :(得分:0)

我有这个问题。我修好了。 使用对象的数组时,请确保已在目标文件中定义了构造函数。

这段代码正在创建错误

List<Prediction> predictions = new ArrayList<Prediction>();

修复。 预测类文件缺少构造函数。在输入默认构造函数后,错误就消失了。

package com.thuptencho.torontotransitbus.models;

public class Prediction {
    public String epochTime = "", seconds = "", minutes = "", isDeparture = "", affectedByLayover = "", branch = "",
            dirTag = "", vehicle = "", block = "", tripTag = "";
    //this constructor was missing..after coding this constructor. the error was gone.
    public Prediction(){
        super();
    }
    @Override
    public String toString() {
        return "epochTime:" + this.epochTime + " seconds:" + this.seconds + " minutes:" + this.minutes
                + " isDeparture:" + this.isDeparture + " affectedByLayover:" + this.affectedByLayover + " branch:"
                + this.branch + " dirTag:" + this.dirTag + " vehicle:" + this.vehicle + " block:" + this.block
                + " triptag:" + this.tripTag;
    }
}