it is possible to check use network provided values chekbox pro-grammatically?I want to check that checkbox using code.How can I do it?

I want to check marked checkbox using programme

有帮助吗?

解决方案 2

Try this:

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

It is not possible to enable it directly from your code. This code will help you to automatically go to that screen.You can then check or uncheck it and then return back to the your screen.

其他提示

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

0 - not checked 1 - checked

Answer Credits Matthias Robbers

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;
        }
    }

This question is similar to: how to turn internet connection (GPRS/EDGE/3G) on/off

Have a look at the project mentioned in the answer:http://code.google.com/p/apndroid/

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top