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

Asked

Viewed 156 times

0

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

But this giving an error in this line in the class usuarioDAO.

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

Error:

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

My variable list is coming null, I believe it’s because of that mistake.

3 answers

1

Check before if the return method is of type Vector, because the compiler is accusing that you are making a direct conversion without checking before the return type.

    if (envelope.getResponse() instanceof Vector) {
        Vector<SoapObject> resposta = (Vector<SoapObject>) envelope.getResponse();
    }

0

Guys I got.

I switched from Arraylist to only Array ai I managed to populate it with the vector. Thank you all.

0

Puts the @SuppressWarnings("unchecked")on top of the statement, thus:

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

If you don’t, let us know.

hugs.

  • Leonardo, the error is gone, but the Array List is still null. I think it’s because I want to populate an array with a vector. I will post here the full code of the web service, the DOC city and the Activity that populates the ok spinner?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.