문제

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