make API level request less crashy

This commit is contained in:
Andrew Dolgov 2011-12-13 15:54:01 +03:00
parent 48751a0071
commit 80a234cc15

View File

@ -1212,11 +1212,15 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
ApiRequest req = new ApiRequest(m_context) { ApiRequest req = new ApiRequest(m_context) {
protected void onPostExecute(JsonElement result) { protected void onPostExecute(JsonElement result) {
m_apiLevel = 0;
if (result != null) { if (result != null) {
m_apiLevel = result.getAsJsonObject() try {
.get("level").getAsInt(); m_apiLevel = result.getAsJsonObject()
} else { .get("level").getAsInt();
m_apiLevel = 0; } catch (Exception e) {
e.printStackTrace();
}
} }
Log.d(TAG, "Received API level: " + m_apiLevel); Log.d(TAG, "Received API level: " + m_apiLevel);