久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

    <tfoot id='GZo5z'></tfoot>
    1. <small id='GZo5z'></small><noframes id='GZo5z'>

      <i id='GZo5z'><tr id='GZo5z'><dt id='GZo5z'><q id='GZo5z'><span id='GZo5z'><b id='GZo5z'><form id='GZo5z'><ins id='GZo5z'></ins><ul id='GZo5z'></ul><sub id='GZo5z'></sub></form><legend id='GZo5z'></legend><bdo id='GZo5z'><pre id='GZo5z'><center id='GZo5z'></center></pre></bdo></b><th id='GZo5z'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='GZo5z'><tfoot id='GZo5z'></tfoot><dl id='GZo5z'><fieldset id='GZo5z'></fieldset></dl></div>
    2. <legend id='GZo5z'><style id='GZo5z'><dir id='GZo5z'><q id='GZo5z'></q></dir></style></legend>

      • <bdo id='GZo5z'></bdo><ul id='GZo5z'></ul>
    3. Appstate 不斷在 Android 中的 React Native 中獲得變化

      Appstate keep on getting change in React native in Android(Appstate 不斷在 Android 中的 React Native 中獲得變化)

      • <small id='rCKVZ'></small><noframes id='rCKVZ'>

          <legend id='rCKVZ'><style id='rCKVZ'><dir id='rCKVZ'><q id='rCKVZ'></q></dir></style></legend>
              <tbody id='rCKVZ'></tbody>
          1. <i id='rCKVZ'><tr id='rCKVZ'><dt id='rCKVZ'><q id='rCKVZ'><span id='rCKVZ'><b id='rCKVZ'><form id='rCKVZ'><ins id='rCKVZ'></ins><ul id='rCKVZ'></ul><sub id='rCKVZ'></sub></form><legend id='rCKVZ'></legend><bdo id='rCKVZ'><pre id='rCKVZ'><center id='rCKVZ'></center></pre></bdo></b><th id='rCKVZ'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='rCKVZ'><tfoot id='rCKVZ'></tfoot><dl id='rCKVZ'><fieldset id='rCKVZ'></fieldset></dl></div>

            <tfoot id='rCKVZ'></tfoot>
                <bdo id='rCKVZ'></bdo><ul id='rCKVZ'></ul>

              • 本文介紹了Appstate 不斷在 Android 中的 React Native 中獲得變化的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                我正在開發 React 本機項目,并且正在獲取位置權限.此外,我必須始終跟蹤位置權限,例如用戶在安裝應用程序后授予權限訪問權限,然后一段時間后用戶轉到設備設置中的應用程序設置并禁用/撤銷權限.再次,一旦應用程序從后臺到前臺,我必須基于此檢查權限,需要顯示消息.

                I am working on React native project and there I am taking location permissions. Also I have to track location permissions always like if user has given permission access after install the application and then after sometime user goes to the app settings in device settings and disable/revoked the permissions. Again once app comes from background to foreground, I have to check permission based on that, Needs to show the messages.

                所以,我正在使用 Appstate.但是,奇怪的是,在 Android 中,安裝應用程序后,如果用戶使用不再顯示"復選框拒絕了該權限,那么 Appstate 會隨著 backgroundactive 不斷變化.它一直在循環.

                So that, I am using Appstate. But, In Android strangely, After installed the application, If user denied the permission with "Dont show again" checkbox, Then Appstate getting keep on changing with background and active always. It is keep on loop.

                componentDidMount = async () => {
                    AppState.addEventListener('change', this.handleAppStateChange);
                  };
                
                  componentWillUnmount() {
                    AppState.removeEventListener('change', this.handleAppStateChange);
                    Geolocation.clearWatch(this.watchID);
                  }
                
                  handleAppStateChange = async nextAppState => {
                    const {appState} = this.state;
                    console.log('nextAppState -->', nextAppState);
                    console.log('appState -->', appState);
                    if (appState === 'active') {
                      // do this
                      this.showLoader();
                      await this.requestAndroidLocationPermission();
                    } else if (appState === 'background') {
                      // do that
                    } else if (appState === 'inactive') {
                      // do that other thing
                    }
                
                    this.setState({appState: nextAppState});
                  };
                
                requestAndroidLocationPermission = async () => {
                    try {
                      const granted = await PermissionsAndroid.request(
                        PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION,
                        {},
                      );
                      if (granted === PermissionsAndroid.RESULTS.GRANTED) {
                        this.getLatitudeLongitude();
                      } else if (granted === PermissionsAndroid.RESULTS.NEVER_ASK_AGAIN) {
                        this.hideLoader();
                        this.setState({
                          errorMessage: 'Location permission is denied',
                          isLoading: false,
                        });
                      } else {
                        this.hideLoader();
                        this.requestAndroidLocationPermission();
                      }
                    } catch (err) {
                      console.warn(err);
                    }
                  };
                

                以不再顯示的方式拒絕許可后繼續打印(循環)

                appState --> active
                nextAppState --> background
                appState --> active
                nextAppState --> background
                appState --> active
                nextAppState --> background
                appState --> active
                

                它繼續,永不停止.

                如何處理?有什么建議嗎?

                How to handle this? Any suggestions?

                推薦答案

                我也遇到了同樣的問題.不要使用 AppState.有問題.

                I had the same problem. Do not use AppState. Is faulty.

                問題在于 RN 對背景"的定義.react-native 使用 android 的活動(UI 線程的持有者和你的 UI 所在的位置)onPause 回調作為發送背景"的觸發器.信號.但是,onPause 每次出現在您的活動視圖層次結構前面時都會調用,例如對話框(例如權限框)、其他活動(例如文件選擇器)等;對于 android react-native,背景";表示被外來 ??UI 元素/android 任務遮蔽";而不是暫停并發送到后臺執行其他操作",從而導致您看到的循環.最短的解決方案是在 ReactActivity 中覆蓋 onPause,并添加控制條件以確保 super.onPause 僅在您實際進入后臺時調用,例如檢查您的任務堆棧,或者是否正在調用權限對話框,因此您避免這種循環/錯誤調用.第二種選擇是提供您自己的應用生命周期事件,并提供明確的觸發條件.

                the problem lies within RN's definition of "background". react-native uses android's activity (the holder of the UI thread and where your UI lives) onPause callback as the trigger for sending the "background" signal. But, onPause is called everytime SOMETHING comes in front of your activity's view hierachy, like Dialogs (like the permission box), other activities (like a file picker), etc; for android react-native, "background" means "shadowed by a foreign UI element/android task" rather than "paused and sent to background to do something else", thus causing the loops you see. The shortest solution is to override onPause in your ReactActivity, and add control conditions to make sure super.onPause is only called when you are actually going to background, like checking your task stack, or if the permission dialog is being called, so you avoid this kind of loop/faulty call. A second option would be to provide your own app lifecycle event instead, with clear triggering conditions.

                這篇關于Appstate 不斷在 Android 中的 React Native 中獲得變化的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                相關文檔推薦

                Help calculating X and Y from Latitude and Longitude in iPhone(幫助從 iPhone 中的緯度和經度計算 X 和 Y)
                Get user#39;s current location using GPS(使用 GPS 獲取用戶的當前位置)
                IllegalArgumentException thrown by requestLocationUpdate()(requestLocationUpdate() 拋出的 IllegalArgumentException)
                How reliable is LocationManager#39;s getLastKnownLocation and how often is it updated?(LocationManager 的 getLastKnownLocation 有多可靠,多久更新一次?)
                CLLocation returning negative speed(CLLocation 返回負速度)
                How to detect Location Provider ? GPS or Network Provider(如何檢測位置提供者?GPS 或網絡提供商)

                <small id='wLJZ0'></small><noframes id='wLJZ0'>

                <tfoot id='wLJZ0'></tfoot>
                    • <i id='wLJZ0'><tr id='wLJZ0'><dt id='wLJZ0'><q id='wLJZ0'><span id='wLJZ0'><b id='wLJZ0'><form id='wLJZ0'><ins id='wLJZ0'></ins><ul id='wLJZ0'></ul><sub id='wLJZ0'></sub></form><legend id='wLJZ0'></legend><bdo id='wLJZ0'><pre id='wLJZ0'><center id='wLJZ0'></center></pre></bdo></b><th id='wLJZ0'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='wLJZ0'><tfoot id='wLJZ0'></tfoot><dl id='wLJZ0'><fieldset id='wLJZ0'></fieldset></dl></div>
                      <legend id='wLJZ0'><style id='wLJZ0'><dir id='wLJZ0'><q id='wLJZ0'></q></dir></style></legend>

                        <tbody id='wLJZ0'></tbody>
                        <bdo id='wLJZ0'></bdo><ul id='wLJZ0'></ul>

                          主站蜘蛛池模板: 久久人人网 | 男人av在线 | 亚洲精品国产电影 | 韩日一区二区三区 | 欧美精品一区二区三 | 精品成人 | 天天干狠狠干 | 青青久久av北条麻妃海外网 | 日本中文在线 | 国产精品久久国产精品 | 久久久久久高潮国产精品视 | 国产成人一区二 | 国产精品一区二区久久 | 亚洲一区不卡 | 国产精品久久久久久久久久久久久 | 在线视频日韩精品 | 日韩精品一区二区三区四区视频 | 日韩精品视频在线观看一区二区三区 | 亚洲网站在线观看 | 国内精品久久久久久久 | 91精品国产一区二区三区 | 亚洲精品视频免费观看 | 天天人人精品 | 岛国午夜| 国产二区视频 | 久久中文视频 | 午夜久久久 | 国产精品久久久久久久久久免费看 | 不卡在线视频 | 在线日韩| 免费国产网站 | 午夜影院操 | 免费观看国产视频在线 | 亚洲精品久久久久久国产精华液 | 特黄色一级毛片 | 亚洲成网 | 狠狠操天天干 | 欧美日韩精品一区二区三区四区 | 欧美日韩国产高清视频 | 夜久久| 狠狠操你 |