Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to call Wi-Fi settings screen from my application using Android

Tags:

android

wifi

Normally I am getting Wi-Fi setting screen on the emulator by clicking on the Settings > Wireless controls > wifi settings. I need to go directly to the Wi-Fi settings screen from my program when pressing on the Wi-Fi button which I have created. Contacts, Call Logs we can handle by using Intent.setData(android.provider.contacts...........). Is there any way to open settings sub-menus/menu from an android program?
Please give me advise or sample code on this.

like image 777
Rajendar Avatar asked Feb 23 '10 13:02

Rajendar


People also ask

How do you use Wi-Fi with Android application?

Android Enable or Disable Wi-Fi Following is the code snippet to enable a Wi-Fi in android application by using setWifiEnabled() method. WifiManager wmgr = (WifiManager)Context. getSystemService(Context. WIFI_SERVICE);

How can I open my Wi-Fi settings?

Click Start, Settings, Network & Internet, and then select the Wi-Fi entry on the left list. Click the Advanced options entry below the last wireless network in the list.

What is the method used to enable the Wi-Fi in Android?

setWifiEnabled(false); So you can enable or disable WiFi using WifiManger class. You need to add extra permissions in AndroidManifest. xml to enable or disable Wifi.


2 Answers

Look at android.provider.Settings for a series of Intent actions you can use to launch various settings screens (e.g., ACTION_WIFI_SETTINGS).

EDIT: Add the coding line.

startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS));

like image 160
CommonsWare Avatar answered Sep 30 '22 10:09

CommonsWare


example

ConnectivityManager manager = (ConnectivityManager)          getSystemService(MainActivity.CONNECTIVITY_SERVICE); /*  * 3G confirm  */ Boolean is3g = manager.getNetworkInfo(         ConnectivityManager.TYPE_MOBILE).isConnectedOrConnecting(); /*  * wifi confirm  */ Boolean isWifi = manager.getNetworkInfo(         ConnectivityManager.TYPE_WIFI).isConnectedOrConnecting(); if (is3g) {     textView.setText("3G"); } else if (isWifi) {     textView.setText("wifi"); } else {     textView.setText("nothing");     // Activity transfer to wifi settings     startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS)); } 
like image 45
kim myoungho Avatar answered Sep 30 '22 09:09

kim myoungho