Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static final String BASE_URL= "http://ashwinku.fwd.wf/ssng-project/api";
- public static final String REGISTER_OPERATION = "/registerUser";
- public static final String LOGIN_OPERATION = "/loginUser";
- public User(String firstName, String password) {
- this.firstName=firstName;
- this.password = password;
- }
- RestAdapter restAdapter = new RestAdapter.Builder()
- .setEndpoint(Constants.BASE_URL)
- .setLogLevel(RestAdapter.LogLevel.FULL)
- .build();
- //Creating object for our interface
- RequestInterface api = restAdapter.create(RequestInterface.class);
- user = new User(firstName,password);
- user.setFirstName(firstName);
- user.setPassword(password);
- //Defining the method insertuser of our interface
- api.loginuser(user, new Callback<User>() {
- @Override
- public void success(User result, Response response) {
- BufferedReader reader = null;
- //An string to store output from the server
- String output = "";
- try {
- //Initializing buffered reader
- reader = new BufferedReader(new InputStreamReader(response.getBody().in()));
- //Reading the output in the string
- output = reader.readLine();
- } catch (IOException e) {
- e.printStackTrace();
- }
- //Displaying the output as a toast
- Toast.makeText(getActivity(), output, Toast.LENGTH_LONG).show();
- }
- @Override
- public void failure(RetrofitError error) {
- Toast.makeText(getActivity(), error.toString(), Toast.LENGTH_LONG).show();
- }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement