Automattic\WPSC\Device_Detection

User_Agent_Info::is_androidpublic staticWPSCache 1.0

Detects if the current browser is the Native Android browser.

Method of the class: User_Agent_Info{}

No Hooks.

Returns

true|false. true if the browser is Android otherwise false

Usage

$result = User_Agent_Info::is_android( $user_agent );
$user_agent(string|null)
User agent string to check. If not provided, uses $_SERVER['HTTP_USER_AGENT'].
Default: null

User_Agent_Info::is_android() code WPSCache 3.1.1

public static function is_android( $user_agent = null ) {
	$user_agent = self::maybe_get_user_agent_from_server( $user_agent );
	if ( empty( $user_agent ) ) {
		return false;
	}

	$agent       = strtolower( wp_unslash( $user_agent ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating.
	$pos_android = strpos( $agent, 'android' );
	if ( false !== $pos_android ) {
		if ( self::is_opera_mini( $user_agent ) || self::is_opera_mobile( $user_agent ) || self::is_firefox_mobile( $user_agent ) ) {
			return false;
		} else {
			return true;
		}
	} else {
		return false;
	}
}