Hi, please clarify how i am supposed to handle errors while making synchronus calls in android api.
For example in the code below,
.....
contributions.setContributor_name( mCurrentUser );
contributions.setContribution_amount( mAmount );
contributions.setFor_month(mFor_month);
contributions.setBalance_carried_forwad( balance );
contributions.setId_no( mUserIdNo );
contributions.setPayment_mode( mPaymentMode );
}
@Override
protected Contributions doInBackground( Integer... params )
{
for (; count <= params[0]; count++) {
try {
Thread.sleep(1000);
publishProgress(count);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
return contributions.save();
}
@Override
protected void onProgressUpdate(Integer... values) {
super.onProgressUpdate(values);
progresBarView.setProgress( values[0] );
}
@Override
protected void onPostExecute(Contributions contributions) {
emptyFields();
showToast( getResources().getString( R.string.save_success ) );
progresBarView.setVisibility( View.GONE );
}
.......
When i a user saves a duplicate value i need to handle the error and prompt him .. how do i catch or handle the response??
Thank you.