Android Open Source - gokit-android Device Ap Activity






From Project

Back to project page gokit-android.

License

The source code is released under:

Copyright (c) 2014~2015 Xtreme Programming Group, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software...

If you think the Android project gokit-android 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

/**
 * Project Name:Gokit//w  w w. j a  v  a2 s  . c o m
 * File Name:DeviceApActivity.java
 * Package Name:com.xpg.gokit.activity
 * Date:2014-11-18 10:04:11
 * Copyright (c) 2014~2015 Xtreme Programming Group, Inc.
 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), 
 * to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, 
 * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */
package com.xpg.gokit.activity;

import java.util.List;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.ConnectivityManager;
import android.net.wifi.ScanResult;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import android.widget.Toast;

import com.xpg.gokit.R;
import com.xpg.gokit.adapter.WifiListAdapter;
import com.xpg.gokit.dialog.SetWifiDialog;
import com.xpg.gokit.dialog.listener.SetWifiListener;
import com.xpg.gokit.utils.NetUtils;
import com.xtremeprog.xpgconnect.XPGWifiSDK;

// TODO: Auto-generated Javadoc
/**
 * softap???????
 * <P>
 * ????airlink????????????????????????softap????????????????????????????app??????
 * ????????????????????ssid????????????Activity??????softap???????????.
 * 
 * @author Lien Li
 */
public class DeviceApActivity extends BaseActivity implements
    OnItemClickListener {

  /** The lv_wifi_list. */
  ListView lv_wifi_list;

  /** wifi???????? */
  List<ScanResult> rs;

  /** wifi???????????? */
  WifiListAdapter adapter;

  /** ??wifi???? */
  SetWifiDialog dialog;

  /** ???????????? */
  ConnecteChangeBroadcast mChangeBroadcast = new ConnecteChangeBroadcast();

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_device_ap);
    initView();
    initData();
    initListener();

    XPGWifiSDK.sharedInstance().getSSIDList();

  }

  /**
   * Inits the view.
   */
  private void initView() {
    lv_wifi_list = (ListView) findViewById(R.id.lv_wifi_list);
  }

  /**
   * Inits the data.
   */
  private void initData() {
    // ?????????????wifi??
    rs = NetUtils.getCurrentWifiScanResult(this);
    adapter = new WifiListAdapter(this, rs);
    lv_wifi_list.setAdapter(adapter);
  }

  public void onResume() {
    super.onResume();
    IntentFilter filter = new IntentFilter();
    filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
    registerReceiver(mChangeBroadcast, filter);
  }

  public void onPause() {
    super.onPause();
    unregisterReceiver(mChangeBroadcast);

  }

  /**
   * Inits the listener.
   */
  private void initListener() {
    lv_wifi_list.setOnItemClickListener(this);
  }

  @Override
  public void onItemClick(AdapterView<?> parent, View v, int pos, long id) {
    ScanResult sResult = rs.get(pos);
    dialog = new SetWifiDialog(this, sResult.SSID);
    dialog.setWifiListener(new SetWifiListener() {

      @Override
      public void set(String ssid, String psw) {
        mCenter.cSetSSID(ssid, psw);

        Toast.makeText(DeviceApActivity.this, "??????",
            Toast.LENGTH_SHORT).show();
      }
    });
    dialog.show();
  }

  /**
   * ????????????wifi?????.
   */
  public class ConnecteChangeBroadcast extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {

      boolean iswifi = NetUtils.isWifiConnected(context);
      Log.i("networkchange", "change" + iswifi);
      if (!iswifi) {
        finish();
      }
    }
  }

}




Java Source Code List

com.xpg.gokit.WApplication.java
com.xpg.gokit.activity.AirLinkActivity.java
com.xpg.gokit.activity.BaseActivity.java
com.xpg.gokit.activity.DeviceApActivity.java
com.xpg.gokit.activity.DeviceListActivity.java
com.xpg.gokit.activity.ForgetPasswordActivity.java
com.xpg.gokit.activity.GokitControlActivity.java
com.xpg.gokit.activity.LoginActivity.java
com.xpg.gokit.activity.MainActivity.java
com.xpg.gokit.activity.RegisterActivity.java
com.xpg.gokit.adapter.DeviceListAdapter.java
com.xpg.gokit.adapter.WifiListAdapter.java
com.xpg.gokit.adapter.WifiSpinnerAdapter.java
com.xpg.gokit.bean.ControlDevice.java
com.xpg.gokit.dialog.SetWifiDialog.java
com.xpg.gokit.dialog.listener.SetWifiListener.java
com.xpg.gokit.sdk.MessageCenter.java
com.xpg.gokit.setting.SettingManager.java
com.xpg.gokit.utils.AssertsUtils.java
com.xpg.gokit.utils.NetUtils.java