| Reply | « Previous Thread | Next Thread » |
|
i am getting a false from base.removeElement(de) whenever i try to remove the item from being broadcasted. it works fine when i run on netbeans but not on the mobile phone. any one knows why?
Code:
public boolean changeContact(String name, boolean isBroadcasted) {
DataElement base = record.getAttributeValue(ATTRIBUTE_ID);
DataElement de = (DataElement)dataElements.get(name);
if (de == null) {
de = new DataElement(DataElement.STRING, name);
dataElements.put(name, de);
}
if (isBroadcasted) {
base.addElement(de);
} else {
if(!base.removeElement(de)){
return false;
}
}
record.setAttributeValue(ATTRIBUTE_ID, base);
try {
localDevice.updateRecord(record);
} catch (ServiceRegistrationException e) {
System.err.println("Can't update record now for: " + name);
return false;
}
System.out.println("updated base");
return true;
}
Last edited by selenatan : 2007-08-24 at 07:13.
|
|
Is this Java? In the future ask questions like those there…
Is the object ‘dataelements’ a Hashtable? First of all make sure, the DataElement ‘de’ is within your list of DataElements (object ‘base’). First check via references (removeElement does this for you), second check via content. The latter cannot be done with removeElement as the class ‘DataElement’ does not implement equals. Please see the JSR-82 API for details. So my guess is, the reference was somehow changed in your real device and you have to remove the DataElement manually via content comparism: de (of dataelements) != de (of base) and false == de.equals(de of base) but de.getValue().equals((de of base).getValue()). So you have to code a bit more. All wild guessing, as I neither know your used device nor have I played with removeElement myself, yet. Just an idea why this workes in IDE and not in real device. |
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|
| Thread | Thread Starter | Forum | Replies | Last Post |
|---|---|---|---|---|
| Python for S60 1.4.0 released | jplauril | Python | 43 | 2009-05-24 10:22 |
| How to port Symbian OS String Descriptors | birol.sekerci | General Symbian C++ | 17 | 2007-11-08 17:24 |
| CMdaAudioOutputStream Not working with EXEDLL target | fnagaton | General Symbian C++ | 6 | 2005-10-03 06:51 |
| 关于Float的问题,急死了,各位帮忙一下,谢谢! | show_up | Other Programming Discussion 关于其他编程技术的讨论 | 4 | 2004-08-17 09:57 |
| How to make singleton | rownak_hasan | Symbian Tools & SDKs | 2 | 2003-02-07 00:15 |