0
gegossen werden, wenn ich versuche, durch „loop für“ iteriert wird, was zu einer schwerwiegenden Ausnahme:Android: Loop für sich java.lang.ClassCastException bekommen: com.google.gson.internal.LinkedTreeMap nicht
java.lang.ClassCastException: com.google.gson.internal.LinkedTreeMap cannot be cast to br.com.gerticonsultoria.easyrentrider.model.ChatUser
at br.com.gerticonsultoria.easyrentrider.MapActivity$1.onReceive(MapActivity.java:272)
at android.support.v4.content.LocalBroadcastManager.executePendingBroadcasts(LocalBroadcastManager.java:297)
at android.support.v4.content.LocalBroadcastManager.access$000(LocalBroadcastManager.java:46)
at android.support.v4.content.LocalBroadcastManager$1.handleMessage(LocalBroadcastManager.java:116)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
ich habe diese Daten:
ArrayList<ChatUser> chatUser2 = intent.getParcelableArrayListExtra("chatUser");
chatUser2 = {[email protected]} size = 2
0 = {[email protected]} size = 14
0 = {[email protected]} "ConnectionId" -> "2500c795-3bad-4543-9905-2693807cc8ea"
key = "ConnectionId"
value = "2500c795-3bad-4543-9905-2693807cc8ea"
1 = {[email protected]} "UserGroup" -> "G"
key = "UserGroup"
value = "G"
2 = {[email protected]} "FgBusy" -> "S"
3 = {[email protected]} "UserType" -> "O"
4 = {[email protected]} "OperatorConnectionId" -> "null"
5 = {[email protected]} "OperatorID" -> "2.0"
6 = {[email protected]} "OperatorName" -> "null"
7 = {[email protected]} "OnlineUsers" -> "0.0"
8 = {[email protected]} "UserID" -> "2.0"
9 = {[email protected]} "UserName" -> "Douglas"
10 = {[email protected]} "CurrentDate" -> "2016-07-18T10:41:31.6714956-03:00"
11 = {[email protected]} "Latitude" -> "47.677928"
12 = {[email protected]} "Longitude" -> "-122.130293"
13 = {[email protected]} "VehicleId" -> "17.0"
1 = {[email protected]} size = 14
0 = {[email protected]} "ConnectionId" -> "9d5fa748-0870-419c-82b3-0a2c2654839e"
1 = {[email protected]} "UserGroup" -> "G"
2 = {[email protected]} "FgBusy" -> "S"
3 = {[email protected]} "UserType" -> "O"
4 = {[email protected]} "OperatorConnectionId" -> "null"
5 = {[email protected]} "OperatorID" -> "1.0"
6 = {[email protected]} "OperatorName" -> "null"
7 = {[email protected]} "OnlineUsers" -> "0.0"
8 = {[email protected]} "UserID" -> "1.0"
9 = {[email protected]} "UserName" -> "Wilian"
10 = {[email protected]} "CurrentDate" -> "2016-07-18T10:41:37.1728196-03:00"
11 = {[email protected]} "Latitude" -> "47.678694"
12 = {[email protected]} "Longitude" -> "-122.130529"
13 = {[email protected]} "VehicleId" -> "16.0"
ich habe versucht, auf diese Weise iterieren:
for (int i = 0; i < chatUser2.size(); i++) {
Log.i("script", "Coords : " + chatUser2.get(i).Latitude + " " + chatUser2.get(i).Longitude);
}
ich andere Wege versucht haben, versucht Gson, itera Tor usw. Aber ich konnte nicht lösen. Jeder kann mir helfen ??
Vielen Dank im Voraus.
wie funktioniert chatUser2 initialisiert und bevölkert werden? – Bill
Ihr JSON-Parser (GSON, glaube ich?) Analysiert dieses Objekt nicht in einer Klasse - so fällt es zurück, es in einen Baum zu verwandeln. Wenn Sie dann versuchen, es als ChatUser zu speichern, löst es eine Ausnahme aus. Veröffentlichen Sie Ihren JSON-Parsing-Code. –
Ich habe die ArrayList vom Abrufen einer Absichtsnachricht ausgefüllt: ArrayList chatUser2 = intent.getParcelableArrayListExtra ("ChatUser"). Ich habe nur Probleme, wenn ich versuche, Daten per Schleife für zu bekommen. –