Skip to Content
Author's profile photo Claudia Pacheco

Customizing MAF Logon Component in Android

Developers can use MAF Logon component to implement quickly the logon UI logic needed to onboard users with SMP 3.0. Although this component is very functional and easy to implement, companies would rarely use its default settings in mobile clients to go live. In this blog will explore some of the settings that can be modified in the MAF Logon component.

Prerequisites

The use of this component requires some dependencies that are described in this document How To… Setup MAF resources in Android Studio  Follow along and you will find that in this document we got an instance of the LogonUIFacade class and initialize it in the onCreate method of the LogonActivity as shown in the following code snippet


Code Snippet – initialize MAF Logon Component (with default settings)

   @Override

       protected void onCreate(Bundle savedInstanceState) {

              super.onCreate(savedInstanceState);

              // set context reference

        Context mContext = this;

              // get an instance of the LogonUIFacade

        LogonUIFacade mLogonUIFacade = LogonUIFacade.getInstance();

              //Initialize the Logon UI Facade

              mLogonUIFacade.init(this, mContext, <name of your application id>);

              // ask LogonUIFacede to present the logon screen

              // set the resulting view as the content view for this activity

        setContentView(mLogonUIFacade.logon());

       }

As a result, the mobile client will display the default screen flow of the MAF Logon component

customMAFOriginal.jpg

Now with few more lines of codes in the onCreate method, you can customize the MAF logon component to simplify the registration process

Step 1-2: Hide MobilePlace Window and then initialize MAF Logon component

In order to hide the MobilePlace window we would need to get the logon core shared preferences settings and modify the mobile place shared property before we get an instance of the LogonUIFacade class.

Code Snippet – Hide MobilePlace window and initialize LogonUIFacade class


//STEP1: Hide MobilePlace window

SharedPreferences prefs = getSharedPreferences(LogonCore.PREFERENCE_FILE_NAME, Context.MODE_PRIVATE);

SharedPreferences.Editor pEditor = prefs.edit();

pEditor.putBoolean(LogonCore.SharedPreferenceKeys.PREFERENCE_ID_MOBILEPLACE.toString(), false);

pEditor.commit();

//STEP2: Get an instance of the LogonUIFacade and initialize it as in the original code

LogonUIFacade mLogonUIFacade = LogonUIFacade.getInstance();

mLogonUIFacade.init(this, this, “<your application id>”);


Step 3: Set Default Values in login fields

Mobile clients require the SMP server URL and port in order to onboard the user with SMP 3.0. However, in most cases companies would like to set these fields with default values and hide them from the final user.  Developers can set default values with the setDefaultValue methods of the LogonUIFacade class as shown following code snippet.

Code Snippet – Set default values


//STEP3: Set Default values

mLogonUIFacade.setDefaultValue(LogonCore.SharedPreferenceKeys.PREFERENCE_ID_SUPSERVERURL, “<your smp server host>”);

mLogonUIFacade.setDefaultValue(LogonCore.SharedPreferenceKeys.PREFERENCE_ID_SUPSERVERPORT, “<your smp server port>”);

//type “true” if the mobile client is using HTTPS, type “false” otherwise

mLogonUIFacade.setDefaultValue(SharedPreferenceKeys.PREFERENCE_ID_HTTPSSTATUS, “<true|false>”);


Step 4: Hide fields in the login details

Generally, users only know their username and passwords. Developers may want to hide the rest of the fields to simplify the registration process. By default, all fields are displayed, hence you only need to specify those fields that are going to be hidden as shown below.

Code Snippet – Hide fields


// STEP4: Hide Login details

mLogonUIFacade.isFieldHidden(LogonCore.SharedPreferenceKeys.PREFERENCE_ID_SUPSERVERURL, true);

mLogonUIFacade.isFieldHidden(LogonCore.SharedPreferenceKeys.PREFERENCE_ID_SUPSERVERPORT, true);

mLogonUIFacade.isFieldHidden(LogonCore.SharedPreferenceKeys.PREFERENCE_ID_SECCONFIG, true);

mLogonUIFacade.isFieldHidden(LogonCore.SharedPreferenceKeys.PREFERENCE_ID_SUPSERVERFARMID, true);

mLogonUIFacade.isFieldHidden(LogonCore.SharedPreferenceKeys.PREFERENCE_ID_URLSUFFIX, true);

mLogonUIFacade.isFieldHidden(LogonCore.SharedPreferenceKeys.PREFERENCE_ID_MOBILEUSER, true); mLogonUIFacade.isFieldHidden(LogonCore.SharedPreferenceKeys.PREFERENCE_ID_ACTIVATIONCODE, true); mLogonUIFacade.isFieldHidden(LogonCore.SharedPreferenceKeys.PREFERENCE_ID_HTTPSSTATUS, true);

mLogonUIFacade.isFieldHidden(LogonCore.SharedPreferenceKeys.PREFERENCE_ID_GATEWAYCLIENT, true);

mLogonUIFacade.isFieldHidden(LogonCore.SharedPreferenceKeys.PREFERENCE_ID_SUPSERVERDOMAIN, true);

mLogonUIFacade.isFieldHidden(LogonCore.SharedPreferenceKeys.PREFERENCE_ID_PINGPATH, true);

mLogonUIFacade.isFieldHidden(LogonCore.SharedPreferenceKeys.PREFERENCE_ID_GWONLY, true);


Step 5: Hide Splash Screen

In order to hide the splash screen, developers need to set the showSplashScreen to false. However, this change restores the default values, so it’s important to call it at the end.

Code Snippet – Hide Splash Screen


// ask LogonUIFacede to present the logon screen

// set the resulting view as the content view for this activity

setContentView(mLogonUIFacade.logon());

// Hide splash screen

mLogonUIFacade.showSplashScreen(false);



After these changes, the new mobile client will display the screen flow of the MAF Logon component  as follows

customMAFModified-nosplash.jpg

Hope this helps,

Claudia

Assigned Tags

      14 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      Hi Claudia Pacheco ,

                while getting the login fade instance , am getting below exception .

      How to solve this error?LogonFade_getInstance().PNG

      Author's profile photo Claudia Pacheco
      Claudia Pacheco
      Blog Post Author

      Hi Sukanya,

      My first guess would be that you are missing some dependencies in your project. Have you completed this guide How To... Setup MAF resources in Android Studio ?

      Best regards

      Claudia

      Author's profile photo Former Member
      Former Member

      Hi Claudia Pacheco,

           I did as follow the above link. But i got the error while getting login fade instance.Config.PNG

      Regards ,

      Sukanya

      Author's profile photo Former Member
      Former Member

      Hi Team,

      How to solve the above error?

      Regards ,

      Sukanya

      Author's profile photo Midhun VP
      Midhun VP

      Hi Sukanya,

      Could you start a new discussion on this since this issue is not related to this blog.

      Regards,Midhun

      SAP Technology RIG

      Author's profile photo Former Member
      Former Member

      Hi Claudia Pacheco,

      I am getting below error when deploying the application on mobile device:

      " Error contacting Client Hub Application "

      How to resolve it ?

      Regards,

      Muhammad

      Author's profile photo Midhun VP
      Midhun VP

      Hi Muhammad,

      I think you could ignore this error. The logonManger is trying to find Client hub application in your device, but it didn't find.

      Client hub a mobile app that comes with SMP. To know more about Client Hub have a look at this blog:2 Steps to Manage Mobile App Registration using Client Hub

      Regards,Midhun

      SAP Technology RIG

      Author's profile photo Former Member
      Former Member

      Hi Midhun,

      My application runs properly and after providing the parameters (Server, Ports, etc) nothing is happening. I am getting below error in android studio:

      04-29 22:50:36.204 19147-19446/com.example.usman.travelagency I/com.sap.smp.request [group: com.sap.smp.client.android] [artifact: Request] [version: 3.7.0] [buildTime: 2015-02-23 21:28] [gitCommit: a0a77a89919c865a32e1d4c67d163d100ccbb660] [gitBranch: rel-3.7]

      04-29 22:50:36.295 19147-19446/com.example.usman.travelagency I/com.sap.smp.request [group: com.sap.smp.client.android] [artifact: Request] [version: 3.7.0] [buildTime: 2015-02-23 21:28] [gitCommit: a0a77a89919c865a32e1d4c67d163d100ccbb660] [gitBranch: rel-3.7]

      04-29 22:50:36.295 19147-19446/com.example.usman.travelagency I/com.sap.smp.coreservices [group: com.sap.smp.client.android] [artifact: CoreServices] [version: 3.7.0] [buildTime: 2015-02-23 21:28] [gitCommit: a0a77a89919c865a32e1d4c67d163d100ccbb660] [gitBranch: rel-3.7]

      04-29 22:50:36.355 19147-19456/com.example.usman.travelagency W/System.err Error: 80003 Message: Unable to reach Backend URL

      04-29 22:50:36.355 19147-19456/com.example.usman.travelagency W/System.err at com.sap.smp.rest.UserManager.registerUser(UserManager.java:211)

      04-29 22:50:36.355 19147-19456/com.example.usman.travelagency W/System.err at com.sap.smp.rest.UserManager$asyncUserRegistration.run(UserManager.java:530)

      04-29 22:50:36.375 19147-19456/com.example.usman.travelagency E/ClientHub Error contacting Client Hub Application

      04-29 22:50:36.375 19147-19456/com.example.usman.travelagency I/ClientHub Pincode not validated yet.

      04-29 22:50:36.375 19147-19456/com.example.usman.travelagency D/MAFLogonActivity onLogonFinished: Host is unreachable!

      04-29 22:50:36.495 19147-19147/com.example.usman.travelagency E/ViewRootImpl sendUserActionEvent() mView == null

        04-29 22:50:41.750 19147-19147/com.example.usman.travelagency W/IInputConnectionWrapper showStatusIcon on inactive InputConnection

      Regards,

      Muhammad

      Author's profile photo Midhun VP
      Midhun VP

      Hi Muhammad,

      The error says unable to reach backend. Check your IP and port, make sure it is accessible from your phone. If you are testing it from internet you have to option the ports.

      You could try using REST client as mentioned here too: SMP 3.0 : REST API Application Development  to double check the ports.

      Regards,Midhun

      SAP Technology RIG

      Author's profile photo Former Member
      Former Member

      Hi Midhun,

      I have checked the ports and i am able to telnet the Server IP on port 8080. But still facing the same error. No clue why its throwing this error.

      Regards,

      Muhammad

      Author's profile photo Midhun VP
      Midhun VP

      Hi Muhammad,

      You could raise a new discussion on this since the question is not related to this blog.

      Firstly, use REST Client to test and make sure you are able to register. Then check the accessibility from device.

      Regards,Midhun

      SAP Technology RIG

      Author's profile photo Former Member
      Former Member

      Hi Midhun,

      I have tested with the REST Client. I am able to test it with the REST client and it is working fine. But still the device is giving the same error.

      Regards,

      Muhammad

      Author's profile photo Former Member
      Former Member

      Hi guys,

       

      I have a problem wich I can't resolve. When I try to change settings and click on "Next" button, I got the message  "NWNative Has Stopped". Therefore, 0 error is detected on my Android Studio.

      Offcourse, I tested to connect with my credentials at hcmps server from a web browser and It's works.

      I'm totally blocked, I hope you will help me to find a solution.

       

      Thank's in advance.

       

       

      Author's profile photo Akos Grabecz
      Akos Grabecz

      Hi,

      That is probably worth an OS update:

      Important: If your PC is producing NWNative.dll errors, you should check your Windows operating system immediately!

      The file NWNative.dll is part of the software CNE Net NetWare 5 Beta 3 from the Novell Inc.. NWNative.dll size is 66048, the version is 1.0.0.0, works on Windows.

      https://www.iremoveerror.com/english/678575/what-is-nwnative-dll-how-to-remove-nwnative-dll-error.html

      Ákos