Android Open Source - Android-Wireless Main Wi Fi A P Activity






From Project

Back to project page Android-Wireless.

License

The source code is released under:

MIT License

If you think the Android project Android-Wireless listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.Nimble.WifiAP;
/*ww  w  . j  a va  2s . c  o m*/
import generics.testingSuite;

import java.lang.reflect.InvocationTargetException;

import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiManager;
import android.os.Bundle;
import android.provider.Settings;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

//getWifiApState...
public class MainWiFiAPActivity extends Activity {

  Boolean initialWiFiSetting;
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
  }
  
  @Override
  protected void onStart() {
    super.onStart();
    setup();
  }
  
  private final void setup()
  {
    WifiManager manager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
    
    /** Disables wifi + 
     * creates a WifiConfiguration with ssid = "TextNetwork", and AuthAlgorithm = open
     */
    WifiConfiguration config = WifiAP.generateDefaultWifiApNetworkSettings(manager, this.getApplicationContext());
    
    setTextView(R.id.textView1, "set");
    
    WifiAP.setWifiApEnabled(manager, config, true); //boolean :)
    
    Log.e(this.getClass().toString(), "WifiAp Enabled");
    
  }
    
  /**
   * 
   * @param id
   * @param text
   * @return The TextView generated, for if it will be used again.
   */
  public final TextView setTextView(int id, String text)
  {
    TextView t = (TextView) findViewById(id);
    t.setText(text);
    return t;
  }
  
  public final String readTextField(int id)
  {
    EditText t = (EditText) findViewById(id);
    return t.getText().toString();
  }
  
  public void executePing(View v)
  {
    String ping = readTextField(R.id.editText1);
    if(ping.length() <= 8)
    {
      setTextView(R.id.textView1, "Incomplete input. Logging IP address");
      testingSuite.getIpAddress();
      return;
    }
    testingSuite.runPing(ping, 2);  
    setTextView(R.id.textView1, "Ping Executed");
  }
  
  /**
   * Restores the phone's settings prior to the app starting.
   */
  @Override
  protected void onDestroy() 
  {
    super.onDestroy();
    Log.w(this.getClass().toString(), "Destroy");
    HardwareStateManager.restore( (WifiManager) getSystemService(Context.WIFI_SERVICE) , this.getApplicationContext());
  }
}




Java Source Code List

com.Nimble.Server.ServerActivity.java
com.Nimble.Server.Server.java
com.Nimble.Server.Sockets.java
com.Nimble.WifiAP.ClientInfo.java
com.Nimble.WifiAP.ClientScanner.java
com.Nimble.WifiAP.HardwareStateManager.java
com.Nimble.WifiAP.MainWiFiAPActivity.java
com.Nimble.WifiAP.WifiAP.java
com.Nimble.WifiAP.scanActivity.java
generics.Methods.java
generics.testingSuite.java