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
1 changed files with 8 additions and 4 deletions

View File

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