android-mesosfer-integration

How to Show and Update Profile Android Mobile Apps in Mesosfer Backend as a Service

How to Show and Update Profile Android Mobile Apps in Mesosfer Backend as a Service

Introduction

This Tutorial is the fourth session of Android Mobile Apps series. You can check the previous session which is How to Build Login and Session Android Mobile Apps in Mesosfer Backend as a ServiceIn this tutorial you will be required some dependency source code you created in the previous session. In this session, we’ll create module to show up and change profile in Android application.

Prerequisites

To follow this tutorial, you will need to prepare these items below :

  • Sign up for an account in Mesosfer Backend as a Service.
  • Install latest android studio. In this tutorial, the author used android studio version 2.2.1
  • Download code from previous section.

Getting Started

In this session, we will show and update user profile. The first step you have to create new activity (ProfileActivity).

how-to-show-and-update-profile-android-mobile-apps-in-mesosfer-backend-as-a-service-profile-activity

Then edit app -> main -> res -> layout -> activity_profile.xml, insert the script below:

Edit Class ProfileActivity then declare the variable input above method onCreate:

Then define init variable into method OnCreate, fill in with TextInput from Layout:

Add fetch user method for load currentUser data then send to method updateView.

In method updateView currentUser data will put in TextInput.

In activity_profile.xml you can see button update profile. You have to add method to handle it.

how-to-show-and-update-profile-android-mobile-apps-in-mesosfer-backend-as-a-service-button-update-profile

Go to ProfileActivity then add method handleUpdateProfile.

You need some validation before running update process.

If validation succeeded, you need to execute update data on method updateProfile.

You have to make little change in layout_main.xml, add this code below, put above button log out.

After you added button profile that navigate to profile page, you also have to add method handleProfile in MainActivity.

If you run the application and login success, it will show result as in picture below:

how-to-show-and-update-profile-android-mobile-apps-in-mesosfer-backend-as-a-service-update-profile

Changes made in smartphone will automatically updated in Mesosfer Backend.

how-to-show-and-update-profile-android-mobile-apps-in-mesosfer-backend-as-a-service-result-cloud

Beside changing user profile data, you can also change password.

how-to-show-and-update-profile-android-mobile-apps-in-mesosfer-backend-as-a-service-button-password

Go to ProfileActivity and insert this method below.

You will need some validation before running update password.

If validation succeeded, you need to execute update password on method updatePassword.

If you run the application, it will show result as in picture below:

how-to-show-and-update-profile-android-mobile-apps-in-mesosfer-backend-as-a-service-update-password

Everything is done! Download full version code here.

Conclusion

We have created module to see and change user profile data. Only by adding two methods which are method retrieve and method update, without creating middleware or SQLlite.

Mesosfer helps you connect your project to the cloud. Cut off the development process so you can straight into the delivery process instead stumble on the complicated infrastructure.

Lead Mobile Software Engineer. Having more than 8 years in IT Consultant. Love working with new mobile platform technology. Expert in Android and iOS Mobile Development.

Leave a Reply