ANDROID - ERROR: Unchecked cast: java.lang.object to java.util.vector

0

I'm trying to fill a% city% according to the selected state in another spinner via spinner .

But this is giving an error in this line in class webservice .

Vector<SoapObject> resposta = (Vector<SoapObject>) envelope.getResponse();

Error:

  

Unchecked cast: java.lang.object to java.util.vector

So my variable list is coming usuarioDAO , I believe it's because of this error.

    
asked by anonymous 26.02.2016 / 15:09

3 answers

1

First check if the method return is of type Vector because the compiler is accusing you that you are doing a direct conversion without first checking the return type.

    if (envelope.getResponse() instanceof Vector) {
        Vector<SoapObject> resposta = (Vector<SoapObject>) envelope.getResponse();
    }
    
26.02.2016 / 15:41
0

Put @SuppressWarnings("unchecked") on top of the declaration, like this:

@SuppressWarnings("unchecked")
Vector<SoapObject> resposta = (Vector<SoapObject>) envelope.getResponse();

If it does not resolve, let us know.

Hugs.

    
26.02.2016 / 15:31
0

I got it.

I changed the ArrayList to Array only so I was able to populate it with the array. Thank you all.

    
29.02.2016 / 14:12