Database Reference
In-Depth Information
try {
JSONObject newRecord = buildRecord();
appendToLog(newRecord);
lastRecord = newRecord;
Intent update = new Intent(LOG_UPDATE);
sendBroadcast(update);
transmit(newRecord);
} catch (JSONException ex) {
Log.e(TAG, "Failed to build JSON record.", ex);
} catch (IOException ex) {
Log.e(TAG, "Could not save record.", ex);
}
}
}
private void transmit(final JSONObject record) {
AsyncTask<Void, Void, Void> task =
new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void… params) {
try {
// Performs the HTTP operation to transmit
the record.
commandRunner.run("record", record);
} catch (ErrorResult e) {
Log.e(TAG, e.getError() + ": " +
e.getMessage());
}
return null;
}
};
task.execute();
}
private JSONObject buildRecord() throws
JSONException {
SharedPreferences prefs =
getSharedPreferences(ManageActivity.PREFS,
MODE_PRIVATE);
Search WWH ::




Custom Search