Class SystemUi


  • public class SystemUi
    extends ApiBindBase
    This class provides System UI related APIs.

    Java Sample Code:

      package com.mitac.api;
    
      import android.app.Activity;
      import android.os.Bundle;
    
      import com.mitac.api.libs.SystemUi;
      import com.mitac.api.libs.ServiceStatusCallback;
    
      public class MainActivity extends Activity {
          private SystemUi mSystemUi;
    
          @Override
          protected void onCreate(Bundle savedInstanceState) {
              super.onCreate(savedInstanceState);
              setContentView(R.layout.activity_main);
    
              // when creating the instance the service is auto binding
              // register a callback to listen service status
              mSystemUi = new SystemUi(getApplicationContext(), new ServiceStatusCallback() {
                  @Override
                  public void ready() {
                      startTest();
                  }
              });
          }
    
          private void startTest() {
              if (mSystemUi != null) {
                  if (!mSystemUi.setFullscreen(true)) { // set as fullscreen
                      // remote fail to do the operation
                  }
              }
          }
    
          @Override
          protected void onStop() {
              super.onStop();
    
              if (mPower != null) {
                  mSystemUi.unbindService();
              }
          }
      }
     

    Kotlin Sample Code:

     package com.mitac.kotlinapitest
    
     import android.content.Context
     import androidx.appcompat.app.AppCompatActivity
     import android.os.Bundle
     import android.util.Log
     import com.mitac.api.libs.SystemUi
     import com.mitac.api.libs.ServiceStatusCallback
    
     class MainActivity : AppCompatActivity() {
         val TAG: String = "SystemUiAPI"
         var systemUi: SystemUi? = null
    
         override fun onCreate(savedInstanceState: Bundle?) {
             super.onCreate(savedInstanceState)
             setContentView(R.layout.activity_main)
             testSystemUiApi(applicationContext)
         }
    
         fun testSystemUiApi(context: Context) {
             systemUi = SystemUi(context, object: ServiceStatusCallback {
                 override fun ready() {
                     Log.d(TAG, "service is ready")
                     systemUi!!.setFullscreen(true)
                 }
    
                 override fun stopped() {
                     Log.d(TAG, "service is stopped")
                 }
             })
         }
     }
     
    • Constructor Summary

      Constructors 
      Constructor Description
      SystemUi​(android.content.Context context)
      This constructor will not bind the service automatically.
      SystemUi​(android.content.Context context, ServiceStatusCallback callback)
      This constructor will bind the service automatically.
    • Constructor Detail

      • SystemUi

        public SystemUi​(android.content.Context context)
        This constructor will not bind the service automatically. Please call bindService() at least once before using APIs.
        Parameters:
        context - better to use Context.getApplicationContext() to prevent memory leaks
        Throws:
        java.lang.IllegalArgumentException - if context is null.
      • SystemUi

        public SystemUi​(android.content.Context context,
                        ServiceStatusCallback callback)
        This constructor will bind the service automatically.
        Parameters:
        context - better to use Context.getApplicationContext() to prevent memory leaks
        callback - used to get the notification when service is ready.
        Throws:
        java.lang.IllegalArgumentException - if context or callback is null.
        See Also:
        ServiceStatusCallback
    • Method Detail

      • setFullscreen

        public boolean setFullscreen​(boolean fullscreen)
        Sets the fullscreen mode.
        Parameters:
        fullscreen - ; true fullscreen; false otherwise
        Returns:
        false if fail
      • hideNavigationBar

        public boolean hideNavigationBar​(boolean hide)
        Hide/Show the navigation bar.
        Parameters:
        hide - true to hide the navigation bar
        Returns:
        false if fail.
      • hideStatusBar

        public boolean hideStatusBar​(boolean hide)
        Hide/Show the status bar.
        Parameters:
        hide - true to hide the status bar
        Returns:
        false if remote fail.