Key Implementation

Modifying the AndroidManifest.xml file

To use the LG QSlide features in applications, developers have to specify the service, library and permissions.

Declaring the FloatingWindowService

All activities that support the LG QSlide features are served by the FloatingWindowService. The service has to be declared in the manifest file of the application.

<application    … >
    <service android:name=
         "com.lge.app.floating.FloatingWindowService">
    </service>
    …
</application>

 

Declaring the library

To use the LG QSlide features on LG smartphones, it is necessary to load the library as follows:

<application    … >
    …
    <uses-library android:name="com.lge.app.floating"
                  android:required="true"/>
</application>

 
If the above lines are not added in the manifest file, the application cannot start as the library is not loaded.

Declaring the library in the manifest file prohibits installation of the application on the devices which have no LG QSlide library. If the android:required attribute is set to ‘false’, the application can be installed on every device. In that case, developers should handle the exception that occurred if the library is absent.

 

Requesting permissions

LG QSlide uses some privileged methods to operate properly. Therefore, applications should acquire permissions for using the methods as follows:

In accordance with Android policy changes, the app which sets its target SDK to Android M cannot use the LG QSlide SDK. Android does not allow 3rd party apps (non-preloaded apps) to use the following permissions required for LG QSlide SDK as of Android M.

 

<manifest … >
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
    <uses-permission android:name="android.permission.REORDER_TASKS" />
    <uses-permission android:name="android.permission.GET_TASKS" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    …
</manifest>

 
For detailed information for each permission, please refer to the Android developer site.

 

Creating an Activity

As mentioned before, developers have to make their activities extend from FloatableActivity to support LG QSlide features.

public class QSlideFloatableActivity extends FloatableActivity {...}

 
All activities inheriting from FloatableActivity are started in a full screen mode in normal case. When other application executes the activity by intent, it is possible for the activity to start in the floating window mode. The QSlide tab in the Notification bar is an example.

 

Switching Display Mode

From full screen mode to floating window mode

Activities can be switched into the floating window mode, when switchToFloatingMode() is invoked.
Simply, the resizable and transparency controllable window will be shown if switchToFloatingMode() is invoked without arguments. However, developers can configure the initial options of the floating window with arguments. There are two methods that help developers to change the initial layout and styles of the floating window.
The following table lists switching method in FloatableActivity. For detailed description, please see the API references.

 

Method name

Description

switchToFloatingMode()

Switch into the floating window with initial layout

switchToFloatingMode(
      boolean useOverlay,
      boolean useOverlappingTitle,
      boolean isResizable,
      Rect initialRegion)

Switch into the floating window and set the styles for the window

switchToFloatingMode(FloatingWindow.LayoutParams params)

Switch into the floating window with the given layout parameter. Developers can get the layout information from other window and set the layout of the window they are creating.

 

From floating window mode to full screen mode

To switch back to the full screen mode in the floating window, developers need to get the instance of the floating window and close it.
FloatableActivity.getFloatingWindow().close(true) closes the window and displays the activity in the full screen mode again. If the argument of close() is ‘false’, the window closes but the activity is not shown again.
 

Between floating window - normal mode and floating window - overlay mode

The transparency of the floating window can be changed by users if the slider which adjusts the transparency is shown in its title bar. Developers can also change the transparency by the FloatableActivity.getFloatingWindow().setOpacity() method. If the argument of the method is less than 1, the window will be transparent and the activity enters the floating window – overlay mode. If the argument is 1, the window switches back to the floating window – normal mode.

Don’t set the argument of setOpacity() to the value greater than 1.

 

Between floating window - normal mode and floating window – low profile mode

Activities will be in the floating window - low profile mode when FloatableActivity.getFloatingWindow().enterLowProfile() is invoked. To switch back to the floating window – normal mode, call the FloatableActivity.getFloatingWindow().exitLowProfile() method.

 

Navigation