3

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

我想使用程序检查标记的复选框

4

3 回答 3

2

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

0 - 未检查 1 - 已检查

答案学分马蒂亚斯强盗

于 2014-06-11T08:51:51.660 回答
0
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/

于 2014-01-08T11:19:05.773 回答
0

尝试这个:

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

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

于 2014-01-08T11:06:45.327 回答