gpt4 book ai didi

android - 从 SoapObject (kSOAP2) 获取 boolean 值

转载 作者:太空狗 更新时间:2023-10-29 16:07:34 26 4
gpt4 key购买 nike

我试图从 SoapObject 中获取一个 boolean 值,我从一个在 Android 中使用 kSOAP2 的网络服务器的响应中得到...

我已将网络调用的响应保存在 SoapObject 中:

SoapObject sResult = (SoapObject)envelope.bodyIn;

我正在遍历响应并获取值

SoapObject soapresults = (SoapObject)sResult.getProperty(0);

for (int i = 0; i < count; i++)
{
SoapObject mail = (SoapObject)soapresults.getProperty(i);

/*Getting the values here*/
}

邮件 SoapObject 将类似于:

MessageInstance=anyType{AuthorName=Børnehaven; CreatedAtUtc=2012-04-10T18:30:00; Id=631; MessageBody=Husk i morgen; Recipient=anyType{FullName=null; Id=2104535421; IsRead=true; ReadAtUtc=2012-04-10T18:30:00; }; };

我唯一难以获取的值是“IsRead”值,我想将其存储为 boolean 值...

我已经尝试了一些事情:

(Boolean)mail.getProperty("IsRead");
((Boolean) mail.getProperty("IsRead")).booleanValue();

但我不断得到:

W/System.err(1283): java.lang.RuntimeException: illegal property: IsRead

正确的获取方式是什么?

最佳答案

试试这个代码 fragment :

SoapObject soRecipient = (SoapObject) mail.getProperty("Recipient");

boolean isRead = Boolean.parseBoolean(soRecipient.getPropertyAsString("IsRead"));
String fullName = soRecipient.getPropertyAsString("FullName");
String id = soRecipient.getPropertyAsString("Id");
String readAtUtc = soRecipient.getPropertyAsString("ReadAtUtc");

关于android - 从 SoapObject (kSOAP2) 获取 boolean 值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10544243/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com