Reputation: 21
Here is my code:
@SuppressWarnings("unchecked")
public List<HashMap<String,Object>> read() {
List<HashMap<String,Object>> listOfFieldValues=null;
try {
uri = URI.create("http://webdev.fritz.box/xmlrpc.php");
client = new XMLRPCClient(uri);
Object[] responseFields=(Object[])client.call("listTrans","ccb48f8cafa83787d6e6f7976e17fa3e", "MusicApp24432");
System.out.println(responseFields.length);
listOfFieldValues=new ArrayList<HashMap<String,Object>>(responseFields.length);
for ( Object objectFields : responseFields) {
listOfFieldValues.add((HashMap<String,Object>)objectFields);
}
}
catch (XMLRPCException e) {
try {
System.out.println(client.call("listTrans","ccb48f8cafa83787d6e6f7976e17fa3e", "MusicApp24432"));
} catch (XMLRPCException e1) {
e1.printStackTrace();
}
System.out.println(e.toString());
}
return listOfFieldValues;
}
I am getting this error at runtime:
04-23 16:43:05.533: E/AndroidRuntime(20787): java.lang.ClassCastException: java.lang.Object[] cannot be cast to java.util.HashMap
I tried all the solution in similar subject and It doesn't work
Upvotes: 0
Views: 859
Reputation: 41168
Your array responseFields
does not contain HashMap
s, so when you try to cast it fails. You need to look in more detail at just what the arrays actually do contain and cast to the correct thing.
You may just need to go another layer deep, or it may be a completely different data structure that you will need to map manually.
Upvotes: 1