We used cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it. What For?

« Back to Blogs

Using Liferay Screenlets in Android Application

Liferay screenlets are visual components that a user insert into an application to use Liferay portal content and services. Liferay screenlets speeds up the development of mobile app which uses Liferay.


Liferay screenlets for android provides screenlets like Login Screenlet, Sign Up Screenlet, Forgot Password Screenlet and many more which a developer can simply integrate with an app. Developer can create his own screenlet if he wants to and can also customize the available screenlet according to the needs.


Here I am going to show how to insert a screenlet in android app which uses Liferay portal. In below example Login screenlet is used. I have used Liferay 6.2 CE GA4 Portal and Android Studio 1.3.2 for this example.  


Prerequisite :

  • Basic knowledge of android and Liferay portal.

  • Android SDK with any IDE (Eclipse or Android Studio etc.) and Liferay should be properly setup.  

Software Requirements:

  • Android Studio 1.0.2 or above.

  • Android SDK 4.0 (API Level 15) or above.

  • Liferay Portal 6.2 CE or EE.


Step-1: Configuring android project to use Liferay screenlet.

Before using liferay screenlets, we need to configure our project with gradle. Following steps are used to configure

Liferay screens in gradle project:


Step-1(A): Add jCenter in build.gradle repositories:

repositories {


Step-1(B): Add liferay screens as a dependencies:

dependencies {

   compile 'com.liferay.mobile:liferay-screens:1.1.+'


Step-1(C): Add following packaging options to build.gradle file, in case if any error such as Duplicate files copied in


android {

   packagingOptions {  

       exclude 'META-INF/LICENSE'

       exclude 'META-INF/NOTICE'




Step-2: Configuring communication between liferay and screenlets.


In your project’s res/values folder, create a new file named as server_context.xml and the below code snippet


<?xml version="1.0" encoding="utf-8"?>


   <!-- Change these values according to your Liferay configuration -->

   <string name="liferay_server"></string>

   <integer name="liferay_company_id">20155</integer>

   <integer name="liferay_group_id">20182</integer>



Server address is corrosponds to http://localhost:8080 through the Android studio’s emulator.


Step-3: Insert screenlet in your android app and configure them.


There are good number of Liferay Screenlets are available for variety of purposes. You just simply insert these available screenlets into your android app and configure according to your requirement. Here I will demonstrate, how to insert Login Screenlet into your android app.


Step-3(A): Open your layout XML file (eg. activity_main.xml) and insert the below Login screenlet layout code in Relative or Fragment Layout:


 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
















       liferay:layoutId="@layout/login_default" />



Step-3(B): To listen the Liferay screenlet’s triggered event, it is needed to implement screenlet’s listener interface in

activity class. Below code snippet shows the LoginListner Implementation:


public class MainActivity implements LoginListener {


protected void onCreate(Bundle savedInstanceState) {



LoginScreenlet loginScreenlet = (LoginScreenlet) findViewById(R.id.login_screenlet);




   public void onLoginSuccess(User user) {



   public void onLoginFailure(Exception e) {




Step-4: Once all the above steps are properly configured, then you can see your first liferay login screenlet to login into liferay server through android app.

For more implementation details or support you may contact us at [email protected].

contact-us Request a callback WhatsApp