Hiiii every one ,
I'm new to this group.Can any 1 please post the code for enabling and
disabling wifi connection that run's on eclipse.I wrote the following
code but it is not running can any 1 please suggest me some
changes ,if possible can anyone send me the code which run's .

Thanx.

package com.abhilash.wifiapp;

import android.app.Activity;
import android.content.Context;
import android.net.wifi.WifiManager;
import android.os.Bundle;
import android.view.View;
import android.widget.*;

public class WifiAppActivity extends Activity {
    WifiManager wm = null;
        /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        wm = (WifiManager) getSystemService(Context.WIFI_SERVICE);

        if(wm.isWifiEnabled())
       {
                setContentView(R.layout.main);
                Button btn_on = (Button) findViewById(R.id.btn_on);
                btn_on.setOnClickListener(new View.OnClickListener() {

                                public void onClick(View v) {
                                        // TODO Auto-generated method stub

                                //      if(!wm.isWifiEnabled())
                                   setContentView(R.layout.alter);


                                }
                        });
        }
        else
        {
                setContentView(R.layout.alter);
                Button btn_off = (Button) findViewById(R.id.btn_off);
                btn_off.setOnClickListener(new View.OnClickListener() {

                                public void onClick(View v) {
                                        // TODO Auto-generated method stub
                                        //if(wm.isWifiEnabled())
                                           setContentView(R.layout.main);


                                }
                        });
        }

    }
}

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to