Check for navigation bar
Took me some time but I've found a more reliable way than relying on hasPermanentMenuKey() which doesn't work for newer phones like the HTC One which have no menu key but do have home & back keys so don't need (or show) the soft navigation bar. To get around this try the following code which checks for a back button too:
boolean hasMenuKey = ViewConfiguration.get(context).hasPermanentMenuKey();
boolean hasBackKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK);
if(!hasMenuKey && !hasBackKey) {
// Do whatever you need to do, this device has a navigation bar
}
How to detect bottom soft navigation bar available in android programmatically?
Following method worked for me and tested in many devices.
public boolean hasNavBar (Resources resources)
{
int id = resources.getIdentifier("config_showNavigationBar", "bool", "android");
return id > 0 && resources.getBoolean(id);
}
Note: Verified this method in real device
iOS - Check for Navigation bar
UINavigationBar
inherits from and has all the fine properties and behaviors of UIView
and one of these properties is hidden
.
So for your view, if you can get a handle to your navigation bar, all you need to do is check to see if hidden
is YES
or NO
.
one way to do this would be to have a UINavigationController property or accessor (setter & getter) for your library so whoever makes use of the library can set the navigation controller and/or bar on your library's behalf.
Related Topics
Singleton Class with Several Different Classloaders
Displaying a Histogram of Image Data
"Java Dateformat Is Not Threadsafe" What Does This Leads To
How Apply CSS on a <H:Inputtext>
Androidruntime Error: Parcel: Unable to Marshal Value
Android Studio Was Unable to Find a Valid Jvm (Related to MAC Os)
How to Change the Text Color in a String to Multiple Colors in Java
Jar Mismatch Found 2 Versions of Android-Support-V4.Jar in the Dependency List
Java.Lang.Nullpointerexception: Attempt to Invoke Virtual Method on a Null Object Reference
Using Custom Font in Android Textview Using Xml
How to Make a Jtable Non-Editable
Java: Why Do You Need to Specify an 'F' in a Float Literal
Unobtrusive Way to Combine and Compress JavaScript/CSS for Java/Spring/Maven Applications