AIDE Tutorial - 53 Change WiFi State
Watch the Video Below:
Main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<Button
android:id="@+id/mainButtonOn"
android:text="Turn On Wifi" android:layout_width="wrap_content" android:layout_height="wrap_content" />
android:id="@+id/mainButtonOn"
android:text="Turn On Wifi" android:layout_width="wrap_content" android:layout_height="wrap_content" />
<Button
android:id="@+id/mainButtonOff"
android:text="Turn Off Wifi" android:layout_width="wrap_content" android:layout_height="wrap_content" />
android:id="@+id/mainButtonOff"
android:text="Turn Off Wifi" android:layout_width="wrap_content" android:layout_height="wrap_content" />
</LinearLayout>
MainActivity.java
package com.kcgroup.CWS;
package com.kcgroup.CWS;
import android.app.*;
import android.os.*;
import android.widget.*;
import android.view.View.*;
import android.view.*;
import android.net.wifi.*;
import android.content.*;
import android.os.*;
import android.widget.*;
import android.view.View.*;
import android.view.*;
import android.net.wifi.*;
import android.content.*;
public class MainActivity extends Activity
{
@Override
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);
setContentView(R.layout.main);
{
@Override
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button btnOn=(Button)findViewById(R.id.mainButtonOn);
btnOn.setOnClickListener(new View.OnClickListener(){
btnOn.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View p1)
{WifiManager wifi=(WifiManager)getSystemService(Context.WIFI_SERVICE);
wifi.setWifiEnabled(true);Toast.makeText(getApplicationContext(),"WiFi is turned ON",Toast.LENGTH_SHORT).show();}});
Button btnOff=(Button)findViewById(R.id.mainButtonOff);
btnOff.setOnClickListener(new View.OnClickListener(){
public void onClick(View p1)
{WifiManager wifi=(WifiManager)getSystemService(Context.WIFI_SERVICE);
wifi.setWifiEnabled(true);Toast.makeText(getApplicationContext(),"WiFi is turned ON",Toast.LENGTH_SHORT).show();}});
Button btnOff=(Button)findViewById(R.id.mainButtonOff);
btnOff.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View p1)
{WifiManager wifi=(WifiManager)getSystemService(Context.WIFI_SERVICE);
wifi.setWifiEnabled(false);Toast.makeText(getApplicationContext(),"WiFi is turned OFF",Toast.LENGTH_SHORT).show();}}); }}
public void onClick(View p1)
{WifiManager wifi=(WifiManager)getSystemService(Context.WIFI_SERVICE);
wifi.setWifiEnabled(false);Toast.makeText(getApplicationContext(),"WiFi is turned OFF",Toast.LENGTH_SHORT).show();}}); }}
Manifest.xml
uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
1.Aide Tutorial - 20 Webviewuses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
2. Aide Tutorial - 20.1 Webview with ProgressBar
3. Aide tutorial - 20.2 webview with back button
4. Aide tutorial - 20.3 webview with exit button
0 comments:
Post a Comment