detno29
detno29

Reputation: 2231

How to turn on 3G, Wifi or GPS in Android?

I am writing an application related to location. Nevertheless, I need to turn on the Wifi/3G and GPS in case it is off before other functions can process. I have searched but I did not see any way to auto turn on 3g/wifi and GPS. How to start this functionality by coding ?

Upvotes: 0

Views: 11176

Answers (2)

johnsonbrown220
johnsonbrown220

Reputation: 1

If you are finding any difficulties in turning on 3G on your Android device then follow the below steps.

  • Tap the Menu icon.
  • Scroll towards right and select settings from the list.
  • Select Wireless Controls or Wireless & networks (as per OS versions).
  • Scroll down to select Mobile Networks.
  • You will get a list on the screen from which you have to select Network Mode.
  • A dialogue box will get populated in front of you with different options like WCDMA only, GSM only and GSM/WCDMA preferred. You have to select GSM/WCDMA preferred option.
  • As soon as you will select this option, 3G is enabled on your phone.

Now if you are in 3G-enabled area and your device is 3G compatible, you are good to enjoy high speed internet services on your mobile phone.

Upvotes: 0

Lucifer
Lucifer

Reputation: 29672

Following Code is use to start Wifi programatically.

WifiManager wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
wifi.setWifiEnabled(enabled);

You need to add following permission in to your AndroidManifest.xml

<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"></uses-permission> 
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"></uses-permission> 

Upvotes: 1

Related Questions