How to disable home key: Difference between revisions

From wizarPOS
No edit summary
 
Line 1: Line 1:
== Disable home key in apk ==
== Disable home key in apk ==
* Define the follow permission, after the permission defined, the app will get the event of home key or back key.
* Defines the following permission, the third-party app will get the event of home key or back key.
* catch the event when the home key or back key has been pressed.
* Catches the event when the home key or back key is pressed.
=== Permission ===
=== Permission ===
   android.permission.CLOUDPOS_DISABLE_HOME_KEY
   android.permission.CLOUDPOS_DISABLE_HOME_KEY
The app declare the permission in manifest.
The app declares the permission in manifest.


== Disable home key in activity ==
== Disable home key in activity ==

Revision as of 03:25, 19 November 2018

Disable home key in apk

  • Defines the following permission, the third-party app will get the event of home key or back key.
  • Catches the event when the home key or back key is pressed.

Permission

 android.permission.CLOUDPOS_DISABLE_HOME_KEY

The app declares the permission in manifest.

Disable home key in activity

Define the follow permission, after the permission defined, then set the activity window type is TYPE_KEYGUARD or TYPE_KEYGUARD_DIALOG, will catch the event when the home key or back key has been 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.