I am new to android, json, processing and stackoverflow, so please bear with me. I took some processing code, made sure it worked, and tried to create an android apk. I have one error that is unresolved. I have a function, int getFeedLength(). It has to catch an exception, and returns a null.
Every time I return a null (replacing it with anything else fails), the Android build fails, and I have looked at a lot of online resources to no avail.
Is there an alternate way to return null, or something else that will allow the build to proceed? I tried float and double, and they all resulted in other types of errors.
Here is the function, if need be, I can share the entire processing sketch:
int getFeedLength() {
int result;
String response = loadStrings(BASE_URL + APIKEY)[0];
if (response != null) {
try {
JSONObject root = new JSONObject(response);
JSONArray feeds = root.getJSONArray("feeds");
result = feeds.length();
println("number of feed entries: " + result);
return result;
}
catch (JSONException e) {
throw new Exception("Unable to perform action such an such");
return null;
}
}
}
Here is the error:
C:\Users\SYAMAN~1\AppData\Local\Temp\android3618104784291490945.pde\src\changethispackage\beforesubmitting\tothemarket\app\app.java:248: incompatible types
[javac] found : <nulltype>
[javac] required: int
[javac] return null;