它表示应用程序如何在以下三种模式中获得导航栏模式
-
手势导航
- 按钮导航
- 两导航
你可以使用下面的代码,可能不适用于所有android设备
public static int isEdgeToEdgeEnabled(Context context) {
Resources resources = context.getResources();
int resourceId = resources.getIdentifier("config_navBarInteractionMode", "integer", "android");
if (resourceId > 0) {
return resources.getInteger(resourceId);
}
return 0;
}
isEdgeToEdgeEnabled函数返回的值如下所示:
导航显示有3个按钮
导航显示为2键(Android p导航模式)
全屏手势(android Q上的手势)
import android.content.Context
import android.provider.Settings
enum class SystemNavigation {
THREE_BUTTON,
TWO_BUTTON,
GESTURE;
companion object {
fun create(context: Context) = values().getOrNull(
Settings.Secure.getInt(context.contentResolver, "navigation_mode", -1)
)
}
}
使用val systemNavigation = SystemNavigation.create(context)