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

From wizarPOS
m (Jeff moved page Disable Home Key to Disable home key)
Line 6: Line 6:
The application declares permissions in the manifest.
The application declares permissions in the manifest.


== Disable Home Key in activity ==
== 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.  
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:
For example:
Line 22: Line 22:
=== Permission ===
=== Permission ===
   android.permission.CLOUDPOS_DISABLE_HOME_KEY_IN_ACTIVITY
   android.permission.CLOUDPOS_DISABLE_HOME_KEY_IN_ACTIVITY
The app declare the permission in manifest.
The application declares permissions in the manifest.

Revision as of 11:03, 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 application declares permissions in the manifest.