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

From wizarPOS
No edit summary
Line 1: Line 1:
== Disable Home Key in APK ==
== Disable home key in APK ==
* Defines the following permission, the third-party app will get the event of home key or back key.
* Define the following permission, and the third-party application will get the home or back key event.
* Catches the event when the home key or back key is pressed.
* Capture events when the home or back key is pressed.
=== Permission ===
=== Permission ===
   android.permission.CLOUDPOS_DISABLE_HOME_KEY
   android.permission.CLOUDPOS_DISABLE_HOME_KEY
The app declares the permission in manifest.
The application declares permissions in the manifest.


== Disable Home Key in activity ==
== Disable Home Key in activity ==

Revision as of 11:00, 15 March 2020

Disable home key in APK

  • Define the following permission, and the third-party application will get the home or back key event.
  • Capture events when the home or back key is pressed.

Permission

 android.permission.CLOUDPOS_DISABLE_HOME_KEY

The application declares permissions in the manifest.

Disable Home Key in activity

Defines the following permission, then sets the activity window type is TYPE_KEYGUARD or TYPE_KEYGUARD_DIALOG, the third-party app will catch the event when the home key or back key is pressed. For example:

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

Permission

 android.permission.CLOUDPOS_DISABLE_HOME_KEY_IN_ACTIVITY

The app declare the permission in manifest.