Skip to content

此页面的翻译正在准备中,暂时显示英文原文。

isAndroid

isAndroid is a utility function that detects whether the current device is running Android. Notes: - All Android browsers include the token "Android" in the user agent.

Interface

ts
function isAndroid(userAgent: string): boolean;

Parameters

  • userAgentstring

    Optional user agent string to check. Defaults to navigator.userAgent.

Return Value

  • boolean

    if the device is running Android, false otherwise. Returns false on server


Example

tsx
if (isAndroid()) {
  // Android-specific code
  enableAndroidOptimizations();
}

基于 MIT 许可证发布。