【问题标题】:How to check Use network-provided values checkbox programatically in android如何在android中以编程方式检查使用网络提供的值复选框
【发布时间】:2014-01-08 10:51:44
【问题描述】:

可以以编程方式检查使用网络提供的值复选框吗?我想使用代码检查该复选框。我该怎么做?

【问题讨论】:

  • 怎么样??你能在这里写代码吗??
  • 好的,我现在给你写
  • 查看我的答案.......但它适用于以上 2.3.......如果需要任何东西,请问我
  • 测试后请接受并+1,它会让我振作起来
  • @SatyakiMukherjee thanx for yr answer..但您的代码似乎是检查移动数据(GPRS)因为我已经使用了这个代码。

标签: android systemtime


【解决方案1】:

android.provider.Settings.System.getInt(getContentResolver(), android.provider.Settings.Global.AUTO_TIME)

0 - 未选中 1 - 选中

Answer Credit Matthias Robbers

【讨论】:

    【解决方案2】:

    试试这个:

    YourActivity.this.startActivity(new Intent(Settings.ACTION_DATE_SETTINGS));
    

    无法直接从您的代码中启用它。此代码将帮助您自动转到该屏幕。然后您可以选中或取消选中它,然后返回到您的屏幕。

    【讨论】:

      【解决方案3】:
      public class ConnectionDetector {
      
              private Context _context;
      
              public ConnectionDetector(Context context){
                  this._context = context;
              }
      
              /**
               * Checking for all possible internet providers
               * **/
              public boolean isConnectingToInternet(){
                  ConnectivityManager connectivity = (ConnectivityManager) _context.getSystemService(Context.CONNECTIVITY_SERVICE);
                    if (connectivity != null)
                    {
                        NetworkInfo[] info = connectivity.getAllNetworkInfo();
                        if (info != null)
                            for (int i = 0; i < info.length; i++)
                                if (info[i].getState() == NetworkInfo.State.CONNECTED)
                                {
                                    return true;
                                }
      
                    }
                    return false;
              }
          }
      

      这个问题类似于: how to turn internet connection (GPRS/EDGE/3G) on/off

      看看答案中提到的项目:http://code.google.com/p/apndroid/

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-08-12
        • 1970-01-01
        • 2019-07-16
        • 2012-10-01
        • 2012-03-09
        • 2012-08-13
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多