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

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

      1. <small id='qARes'></small><noframes id='qARes'>

        如何以编程方式检查 Android 中互联网连接的可用性?

        How to programmatically check availibilty of internet connection in Android?(如何以编程方式检查 Android 中互联网连接的可用性?)

        <i id='i5577'><tr id='i5577'><dt id='i5577'><q id='i5577'><span id='i5577'><b id='i5577'><form id='i5577'><ins id='i5577'></ins><ul id='i5577'></ul><sub id='i5577'></sub></form><legend id='i5577'></legend><bdo id='i5577'><pre id='i5577'><center id='i5577'></center></pre></bdo></b><th id='i5577'></th></span></q></dt></tr></i><div id='i5577'><tfoot id='i5577'></tfoot><dl id='i5577'><fieldset id='i5577'></fieldset></dl></div>
      2. <small id='i5577'></small><noframes id='i5577'>

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

              • <legend id='i5577'><style id='i5577'><dir id='i5577'><q id='i5577'></q></dir></style></legend>

                  <tfoot id='i5577'></tfoot>
                  本文介绍了如何以编程方式检查 Android 中互联网连接的可用性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想以编程方式检查 Android 手机/模拟器中是否有互联网连接.因此,一旦我确定存在互联网连接,我就会拨打互联网电话.

                  I want to check programmatically whether there is an internet connection in Android phone/emulator. So that once I am sure that an internet connection is present then I'll make a call to the internet.

                  所以它就像嘿模拟器!如果你有互联网连接,那么请打开这个页面,否则 doSomeThingElse();"

                  So its like "Hey emulator! If you have an internet connection, then please open this page, else doSomeThingElse();"

                  推荐答案

                  我自己实现的方法:

                  /*
                   * isOnline - Check if there is a NetworkConnection
                   * @return boolean
                   */
                  protected boolean isOnline() {
                      ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
                      NetworkInfo netInfo = cm.getActiveNetworkInfo();
                      if (netInfo != null && netInfo.isConnected()) {
                          return true;
                      } else {
                          return false;
                      }
                  }
                  

                  请注意,这是一个 NetworkConnection-Check.如果有 NetworkConnection,它不一定是 InternetConnection.

                  Be aware of that this is a NetworkConnection-Check. If there is a NetworkConnection it doesn't have to be a InternetConnection.

                  这篇关于如何以编程方式检查 Android 中互联网连接的可用性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Lucene Porter Stemmer not public(Lucene Porter Stemmer 未公开)
                  How to index pdf, ppt, xl files in lucene (java based or python or php any of these is fine)?(如何在 lucene 中索引 pdf、ppt、xl 文件(基于 java 或 python 或 php 中的任何一个都可以)?)
                  KeywordAnalyzer and LowerCaseFilter/LowerCaseTokenizer(KeywordAnalyzer 和 LowerCaseFilter/LowerCaseTokenizer)
                  How to search between dates (Hibernate Search)?(如何在日期之间搜索(休眠搜索)?)
                  How to get positions from a document term vector in Lucene?(如何从 Lucene 中的文档术语向量中获取位置?)
                  Java Lucene 4.5 how to search by case insensitive(Java Lucene 4.5如何按不区分大小写进行搜索)
                    <tbody id='e9DJB'></tbody>

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

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