Best practice - How to consider virtual Menu Keys (Android Implementation)
Hi,
We currently are developping an application using your awesome nativescript-angular framework, but some practices are still hard to determine for us.
Our issue is simple : we are targetting android devices with and without the permanent menu key. What I am missing is the way to get the information if the device has this famous permanent menu key.
With android, I would have used this :
ViewConfiguration.hasPermanentMenuKey()
But with nativescript-angular, I'm not sure on how to adress this. I've been trying to get it through app.android.context, but no matter what, I'm unable to exctract this information.
Any help/Best practice to take in account the virtual menu key ?
Thanks !
We don't have a concrete best practice about that. Here is how i managed to get hold of a ViewConfiguration object and call the hasPermanentMenuKey():
import * as application from "application";
import { nativeScriptBootstrap } from "nativescript-angular/application";
declare var android: any;
// ...
nativeScriptBootstrap(AppComponent).then(() => {
if (application.android) {
var context = application.android.context;
var viewConfig = (<any>android).view.ViewConfiguration.get(context);
console.log("-------- hasPermanentMenuKey: " + viewConfig.hasPermanentMenuKey());
}
})
One thing to keep in mind is that the application.android.context is not available immediately - that's why I use the promise returned by the bootstrap and do the check there, when the application is initialized.