@Override protected void onPostExecute(String result) { // Log.e("Joseph", result); Gson gson = new Gson(); Authorisation auth = gson.fromJson(result, Authorisation.class); String error = auth.getError(); if (error.equals("false")) { // User has logged in successfully and api key has been issued // Send data to FragmentActivity by hooking into UI event APIKEY = auth.getApikey(); if (mListener != null) { String[] authDetails = {auth.getName(), auth.getEmail(), auth.getApikey()}; mListener.onFragmentInteraction(authDetails); Toast.makeText(getActivity(), auth.getMessage(), Toast.LENGTH_SHORT).show(); // Update the list in the Drawer so that it can show logout CloseFragment(); } } else { // Login failed because error was returned from service registerFailed.setText(auth.getMessage()); registerFailed.setTextColor(Color.RED); Name.setText(""); Email.setText(""); Password.setText(""); ConfirmPassword.setText(""); Name.requestFocus(); } }