我想在我的react原生android应用程序中启用自动亮度。例如,用户能够在点击按钮时启用自动亮度。我该怎么做呢?
xu3bshqb1#
您可以使用此软件包expo-brightness www.example.com实现此https://docs.expo.dev/versions/latest/sdk/brightness/#brightnesssetsystembrightnessmodeasyncbrightnessmode
expo-brightness
import React, { useEffect } from 'react'; import { StyleSheet, View, Text } from 'react-native'; import * as Brightness from 'expo-brightness'; export default function App() { useEffect(() => { (async () => { const { status } = await Brightness.requestPermissionsAsync(); if (status === 'granted') { // ANDROID ONLY Brightness.setSystemBrightnessModeAsync(BrightnessMode.AUTOMATIC) } })(); }, []); return ( <View style={styles.container}> <Text>Brightness Module Example</Text> </View> ); }
如果您在世博会项目之外使用,请遵循以下说明:https://github.com/expo/expo/tree/sdk-47/packages/expo-brightness
1条答案
按热度按时间xu3bshqb1#
您可以使用此软件包
expo-brightness
www.example.com实现此https://docs.expo.dev/versions/latest/sdk/brightness/#brightnesssetsystembrightnessmodeasyncbrightnessmode如果您在世博会项目之外使用,请遵循以下说明:https://github.com/expo/expo/tree/sdk-47/packages/expo-brightness