Package com.mitac.api.libs
Class SystemUi
- java.lang.Object
-
- com.mitac.api.libs.ApiBindBase
-
- com.mitac.api.libs.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.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
bindService()
Bind serviceboolean
hideNavigationBar(boolean hide)
Hide/Show the navigation bar.boolean
hideStatusBar(boolean hide)
Hide/Show the status bar.boolean
setFullscreen(boolean fullscreen)
Sets the fullscreen mode.void
unbindService()
Unbind service
-
-
-
Constructor Detail
-
SystemUi
public SystemUi(android.content.Context context)
This constructor will not bind the service automatically. Please callbindService()
at least once before using APIs.- Parameters:
context
- better to useContext.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 useContext.getApplicationContext()
to prevent memory leakscallback
- 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.
-
bindService
public void bindService()
Bind service- Specified by:
bindService
in classApiBindBase
-
unbindService
public void unbindService()
Unbind service- Specified by:
unbindService
in classApiBindBase
-
-