aditya-narain / google-voice-java

Automatically exported from code.google.com/p/google-voice-java
0 stars 0 forks source link

NullPointerException from SMSParser. Voice.getSMSThreads... #33

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
My App Engine app retrieves SMS messages from Google Voice using this
API. It worked before, but  started crashed from today. I am not sure
if I made any changes. The crash caused when my app tries to call
"voice.getSMStreads()". It triggers the following exception:

Caused by: java.lang.NullPointerException
       at
com.techventus.server.voice.util.SMSParser.parseContact(SMSParser.java:
125)
       at
com.techventus.server.voice.util.SMSParser.getSMSThreads(SMSParser.java:
106)
       at com.techventus.server.voice.Voice.getSMSThreads(Voice.java:688)

Could anyone please provide any insight about how to solve this
problem? Thank you very much!

Original issue reported on code.google.com by malone.j...@gmail.com on 19 Mar 2012 at 8:48

GoogleCodeExporter commented 8 years ago
The voice.getSMSTreads() still produces the same error as I mentioned in the 
Google Group. Instead, I read SMS directly from the JSON response. And it works 
now, but I can read only the latest SMS in each tread. Here is the code I wrote:

//After Voice setup
String unReadSMSXML = voice.getUnreadSMS();
jsonString = parseXML(unReadSMSXML);
JSONObject json = new JSONObject(jsonString);
JSONObject smsObjects = json.getJSONObject("messages");
if(smsObjects.length() != 0){

     Date now = ServerTimeManipulator.getCurrentTime();
     ArrayList<String> keys = getKeys(jsonString); //the code I wrote that gets only key for each SMS
     readMessages = keys.size();

     for(int i=0; i< keys.size(); i++){
          String currentKey = keys.get(i);
          JSONObject oneMessageJsonObject = (JSONObject) smsObjects.get(currentKey);
          boolean read = (Boolean) oneMessageJsonObject.get("isRead");
          if(!read){
               String phoneNumber = (String) oneMessageJsonObject.get("phoneNumber");
               String messageText = (String) oneMessageJsonObject.get("messageText");
               //Process message
          }
     }
}

Original comment by malone.j...@gmail.com on 20 Mar 2012 at 3:23

GoogleCodeExporter commented 8 years ago
RI believe Google made a temporary breaking change that has now been fixed.  I 
want to close off this issue if possible.

Original comment by malone.j...@gmail.com on 25 Mar 2012 at 2:04

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
I get basically this same error. I posted a separate issue report for it.

Original comment by cs3vi...@gmail.com on 8 Nov 2013 at 2:33