How to Disable the Home Key in APK and Activity: Difference between revisions

From wizarPOS
No edit summary
No edit summary
Line 1: Line 1:
== Disable home key in APK ==
== Disabling Home Key in APK ==
Please download the demo [http://ftp.wizarpos.com/advanceSDK/DisableStatusBarOrHomeBtnInApp.zip here].
* '''Overview:''' This section explains how to disable the home key within an Android application (APK).
 
* '''Demo Availability:''' Access a practical demonstration by downloading the provided [http://ftp.wizarpos.com/advanceSDK/DisableStatusBarOrHomeBtnInApp.zip demo].
* Define the following permission, and the third-party application will get the home or back key event.
* '''Setting Permissions:''' Define specific permissions in your application to capture home or back key events.
* Capture events when the home or back key is pressed.
* '''Capturing Key Events:''' Implement functionality to detect when the home or back key is pressed within the application.
=== Permission ===
=== <big>Permission</big> ===
   android.permission.CLOUDPOS_DISABLE_HOME_KEY
   android.permission.CLOUDPOS_DISABLE_HOME_KEY
The application declares permissions in the manifest.
The application declares permissions in the manifest.
 
== Disabling Home Key in Activity ==
== Disable home key in activity ==
* '''Overview:''' This part focuses on disabling the home key specifically in an Android activity.
Please download the demo [http://ftp.wizarpos.com/advanceSDK/DisableStatusBarOrHomeBtnInActivityInW1.zip here].
* '''Demo Availability:''' A demo for this functionality is available for download [http://ftp.wizarpos.com/advanceSDK/DisableStatusBarOrHomeBtnInActivityInW1.zip demo].
 
* '''Defining Permissions and Window Type:'''
Define the following permission, and then set the window type of the activity to TYPE_KEYGUARD or TYPE_KEYGUARD_DIALOG. When you press home or back key, the third-party application will capture the event.  
** Set necessary permissions in your activity.
=== Permission ===
** Change the window type of the activity to either ''''TYPE_KEYGUARD'''' or ''''TYPE_KEYGUARD_DIALOG''''.
* '''Event Capture:''' With these settings, the application will be able to capture events when the home or back key is pressed.
=== <big>Permission</big> ===
   android.permission.CLOUDPOS_DISABLE_HOME_KEY_IN_ACTIVITY
   android.permission.CLOUDPOS_DISABLE_HOME_KEY_IN_ACTIVITY
The application declares permissions in the manifest.
The application declares permissions in the manifest.

Revision as of 22:24, 9 January 2024

Disabling Home Key in APK

  • Overview: This section explains how to disable the home key within an Android application (APK).
  • Demo Availability: Access a practical demonstration by downloading the provided demo.
  • Setting Permissions: Define specific permissions in your application to capture home or back key events.
  • Capturing Key Events: Implement functionality to detect when the home or back key is pressed within the application.

Permission

 android.permission.CLOUDPOS_DISABLE_HOME_KEY

The application declares permissions in the manifest.

Disabling Home Key in Activity

  • Overview: This part focuses on disabling the home key specifically in an Android activity.
  • Demo Availability: A demo for this functionality is available for download demo.
  • Defining Permissions and Window Type:
    • Set necessary permissions in your activity.
    • Change the window type of the activity to either 'TYPE_KEYGUARD' or 'TYPE_KEYGUARD_DIALOG'.
  • Event Capture: With these settings, the application will be able to capture events when the home or back key is pressed.

Permission

 android.permission.CLOUDPOS_DISABLE_HOME_KEY_IN_ACTIVITY

The application declares permissions in the manifest.

The code snippet is as follows:

public void onAttachedToWindow() {                                      
	super.onAttachedToWindow();                                           
	try {                                                                 
		this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD); 
	} catch (Throwable e) {                                               
		e.printStackTrace();                                                
	}                                                                     
}