You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

@react-native-community/blur在一加Android 12设备应用后台/非活跃状态下失效问题求助

@react-native-community/blur在一加Android 12设备应用后台/非活跃状态下失效问题求助

大家好,我在React Native项目(v0.75.3)里用了@react-native-community/blur(v4.4.1),用来在应用进入后台时覆盖整个UI做隐私模糊,现在碰到了一个设备特定的问题,想请教下社区的朋友们有没有类似经验或者解决思路?

我测试下来的情况是:

  • 模糊效果在这些设备上正常工作:Android 11 设备、Android 13 设备
  • 但在一加Android 12设备上,当应用进入后台或非活跃状态时,这个模糊完全不生效

我做这个的目的是防止别人从最近应用列表里看到App内的敏感内容,这个逻辑在大部分设备上都跑通了,唯独卡在一加Android 12上。

相关依赖版本

  • @react-native-community/blur: 4.4.1
  • react-native: 0.75.3

我实现的代码逻辑

下面是处理后台状态模糊的组件代码,通过监听AppState的blur/focus事件来控制模糊层的显示:

import React, { useEffect, useState } from 'react';
import { AppState, Platform, StyleSheet } from 'react-native';
import { BlurView } from '@react-native-community/blur';

const BackgroundStateAndroidBlur = () => {
  const [isBlurred, setIsBlurred] = useState(false);

  useEffect(() => {
    if (Platform.OS === 'android') {
      /**
       * /!\
       * Be aware that this event will be triggered also when a modal is opened
       * so be careful where you use this component
       */
      const blurEventListener = AppState.addEventListener('blur', () => {
        setIsBlurred(true);
      });

      const focusEventListener = AppState.addEventListener('focus', () => {
        setIsBlurred(false);
      });

      return () => {
        blurEventListener.remove();
        focusEventListener.remove();
      };
    }
  }, []);

  return (
    isBlurred && (
      <BlurView
        style={styles.absolute}
        blurType="light"
        blurAmount={10}
        reducedTransparencyFallbackColor="white"
      />
    )
  );
};

const styles = StyleSheet.create({
  absolute: {
    position: 'absolute',
    top: 0,
    left: 0,
    right: 0,
    bottom: 0,
  },
});

export default BackgroundStateAndroidBlur;

想请教的问题

  1. 有没有人在一加Android 12设备上遇到过同样的@react-native-community/blur失效问题?
  2. 有没有已知的解决方案或者临时 workaround?
  3. 会不会是一加设备的特定系统设置(比如隐私、显示相关)影响了模糊效果的渲染?

非常感谢大家的任何见解和建议!

内容来源于stack exchange

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.08 10:49:36