Skip to content

Commit be41345

Browse files
JAVATECHIGJAVATECHIG
authored andcommitted
Added How to Turn off, Turn on wifi in android using code
1 parent 3b93ea7 commit be41345

File tree

16 files changed

+184
-0
lines changed

16 files changed

+184
-0
lines changed

TurnWifi/AndroidManifest.xml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.example.wifitest"
4+
android:versionCode="1"
5+
android:versionName="1.0" >
6+
7+
<uses-sdk
8+
android:minSdkVersion="14"
9+
android:targetSdkVersion="17" />
10+
11+
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
12+
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
13+
<uses-permission android:name="android.permission.WAKE_LOCK" />
14+
15+
<application
16+
android:allowBackup="true"
17+
android:icon="@drawable/ic_launcher"
18+
android:label="@string/app_name"
19+
android:theme="@style/AppTheme" >
20+
<activity
21+
android:name="com.example.wifitest.MainActivity"
22+
android:label="@string/app_name" >
23+
<intent-filter>
24+
<action android:name="android.intent.action.MAIN" />
25+
26+
<category android:name="android.intent.category.LAUNCHER" />
27+
</intent-filter>
28+
</activity>
29+
</application>
30+
31+
</manifest>
7.48 KB
Loading

TurnWifi/res/drawable-hdpi/wifi.png

37.2 KB
Loading
3.69 KB
Loading
12.2 KB
Loading
24.2 KB
Loading

TurnWifi/res/layout/activity_main.xml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
2+
xmlns:tools="http://schemas.android.com/tools"
3+
android:layout_width="match_parent"
4+
android:layout_height="match_parent"
5+
tools:context=".MainActivity" >
6+
7+
<ImageView
8+
android:id="@+id/imageView1"
9+
android:layout_width="wrap_content"
10+
android:layout_height="wrap_content"
11+
android:layout_centerInParent="true"
12+
android:src="@drawable/wifi" />
13+
14+
<Switch
15+
android:id="@+id/wifi_switch"
16+
android:layout_width="wrap_content"
17+
android:layout_height="wrap_content"
18+
android:layout_alignParentBottom="true"
19+
android:layout_marginBottom="10dp"
20+
android:background="@android:color/background_dark"
21+
android:checked="false"
22+
android:text="Wi-Fi Settings"
23+
android:textColor="@android:color/white"
24+
android:textOff="OFF"
25+
android:textOn="ON" />
26+
27+
</RelativeLayout>

TurnWifi/res/menu/main.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
2+
3+
<item
4+
android:id="@+id/action_settings"
5+
android:orderInCategory="100"
6+
android:showAsAction="never"
7+
android:title="@string/action_settings"/>
8+
9+
</menu>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<resources>
2+
3+
<!--
4+
Customize dimensions originally defined in res/values/dimens.xml (such as
5+
screen margins) for sw600dp devices (e.g. 7" tablets) here.
6+
-->
7+
8+
</resources>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<resources>
2+
3+
<!--
4+
Customize dimensions originally defined in res/values/dimens.xml (such as
5+
screen margins) for sw720dp devices (e.g. 10" tablets) in landscape here.
6+
-->
7+
<dimen name="activity_horizontal_margin">128dp</dimen>
8+
9+
</resources>

0 commit comments

Comments
 (0)