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

From wizarPOS
No edit summary
(Replaced content with "{{Migrating|https://smartpossdk.gitbook.io/cloudpossdk/faq/other-development/disable-home-key}}")
Tag: Replaced
 
(2 intermediate revisions by one other user not shown)
Line 1: Line 1:
== Disable home key in APK ==
{{Migrating|https://smartpossdk.gitbook.io/cloudpossdk/faq/other-development/disable-home-key}}
Please download the demo [http://ftp.wizarpos.com/advanceSDK/DisableStatusBarOrHomeBtnInApp.zip here].
 
* 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 ==
Please download the demo [http://ftp.wizarpos.com/advanceSDK/DisableStatusBarOrHomeBtnInActivityInW1.zip here].
 
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.
=== Permission ===
  android.permission.CLOUDPOS_DISABLE_HOME_KEY_IN_ACTIVITY
The application declares permissions in the manifest.
 
The code snippet is as follows:
<syntaxhighlight lang="java">
public void onAttachedToWindow() {                                     
super.onAttachedToWindow();                                         
try {                                                               
this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD);
} catch (Throwable e) {                                             
e.printStackTrace();                                               
}                                                                    
}                                                                     
 
</syntaxhighlight >

Latest revision as of 03:24, 8 April 2024

Please visit new link of same subject:

https://smartpossdk.gitbook.io/cloudpossdk/faq/other-development/disable-home-key

We're making a move! Our site's content is migrating to a new URL, to provide you with an enhanced browsing experience. Please update your bookmarks accordingly. Thank you for your continuous support!