I’m trying to get the fault code using the Async Backendless Register service and then based on the code number eg - 3033, I want to display a message showing what the error is. When I run the code shown below, it shows me the error message on the Android logcat. But the toast (i.e message) doesn’t appear on the phone screen. What could be the problem?
Here is my code:
Backendless.UserService.register(newuser, new BackendlessCallback<BackendlessUser>() {
@Override
public void handleResponse(BackendlessUser backendlessUser) {
}
public void handleFault(BackendlessFault fault)
{
String faultcode = fault.getCode();
Log.i("E",faultcode);
if(faultcode=="2002"||faultcode=="3009"||faultcode=="3010"||faultcode=="3014"||faultcode=="3038"||faultcode=="3039"||faultcode=="3040"||faultcode=="3041"||faultcode=="3043"){
Context context = getApplicationContext();
CharSequence text = "Internal Server error";
int duration = Toast.LENGTH_SHORT;
Toast toast = Toast.makeText(context, text, duration);
toast.show();
}
else if(faultcode=="3033"){
Context context1 = getApplicationContext();
CharSequence text1 = "User already exists";
int duration1 = Toast.LENGTH_SHORT;
Toast toast1 = Toast.makeText(context1, text1, duration1);
toast1.show();
}
}
});