Android 连接Wifi和创建Wifi热点 demo
- android的热点功能不可见,用了反射的技术搞定之外。
- Eclipse设置语言为utf-8才能查看中文注释
上代码:
MainActivity.java
- package com.widget.hotspot;
- import android.os.Bundle;
- import android.app.Activity;
- import android.content.BroadcastReceiver;
- import android.content.Context;
- import android.content.Intent;
- import android.content.IntentFilter;
- import android.util.Log;
- import android.view.Menu;
- import android.view.View;
- import android.widget.Button;
- public class MainActivity extends Activity {
- public static final String TAG = "MainActivity";
- private Button mBtn1, mBtn2;
- private WifiAdmin mWifiAdmin;
- private Context mContext = null;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- mContext = this;
- setContentView(R.layout.activity_main);
- mBtn1 = (Button)findViewById(R.id.button1);
- mBtn2 = (Button)findViewById(R.id.button2);
- mBtn1.setText("点击连接Wifi");
- mBtn2.setText("点击创建Wifi热点");
- mBtn1.setOnClickListener(new Button.OnClickListener() {
- @Override
- public void onClick(View v) {
- // TODO Auto-generated method stub
- mWifiAdmin = new WifiAdmin(mContext) {
- @Override
- public void myUnregisterReceiver(BroadcastReceiver receiver) {
- // TODO Auto-generated method stub
- MainActivity.this.unregisterReceiver(receiver);
- }
- @Override
- public Intent myRegisterReceiver(BroadcastReceiver receiver,
- IntentFilter filter) {
- // TODO Auto-generated method stub
- MainActivity.this.registerReceiver(receiver, filter);
- return null;
- }
- @Override
- public void onNotifyWifiConnected() {
- // TODO Auto-generated method stub
- Log.v(TAG, "have connected success!");
- Log.v(TAG, "###############################");
- }
- @Override
- public void onNotifyWifiConnectFailed() {
- // TODO Auto-generated method stub
- Log.v(TAG, "have connected failed!");
- Log.v(TAG, "###############################");
- }
- };
- mWifiAdmin.openWifi();
- mWifiAdmin.addNetwork(mWifiAdmin.createWifiInfo("YOU_WIFI", "MM123456", WifiAdmin.TYPE_WPA));
- }
- });
- mBtn2.setOnClickListener(new Button.OnClickListener() {
- @Override
- public void onClick(View v) {
- // TODO Auto-generated method stub
- WifiApAdmin wifiAp = new WifiApAdmin(mContext);
- wifiAp.startWifiAp("\"HotSpot\"", "hhhhhh123");
- }
- });
- }
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- // Inflate the menu; this adds items to the action bar if it is present.
- getMenuInflater().inflate(R.menu.activity_main, menu);
- return true;
- }
- @Override
- public void onResume() {
- super.onResume();
- Log.d("Rssi", "Registered");
- }
- @Override
- public void onPause() {
- super.onPause();
- Log.d("Rssi", "Unregistered");
- }
- }
WifiAdmin.java
参考了://http://blog.csdn.net/yuanbohx/article/details/8109042
- package com.widget.hotspot;
- import java.util.List;
- import java.util.Timer;
- import java.util.TimerTask;
- import android.content.BroadcastReceiver;
- import android.content.Context;
- import android.content.Intent;
- import android.content.IntentFilter;
- import android.net.ConnectivityManager;
- import android.net.NetworkInfo;
- import android.net.NetworkInfo.DetailedState;
- import android.net.wifi.ScanResult;
- import android.net.wifi.WifiConfiguration;
- import android.net.wifi.WifiInfo;
- import android.net.wifi.WifiManager;
- import android.net.wifi.WifiManager.WifiLock;
- import android.util.Log;
- public abstract class WifiAdmin {
- private static final String TAG = "WifiAdmin";
- private WifiManager mWifiManager;
- private WifiInfo mWifiInfo;
- // 扫描出的网络连接列表
- private List<ScanResult> mWifiList;
- private List<WifiConfiguration> mWifiConfiguration;
- private WifiLock mWifiLock;
- private String mPasswd = "";
- private String mSSID = "";
- private Context mContext = null;
- public WifiAdmin(Context context) {
- mContext = context;
- // 取得WifiManager对象
- mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
- // 取得WifiInfo对象
- mWifiInfo = mWifiManager.getConnectionInfo();
- Log.v(TAG, "getIpAddress = " + mWifiInfo.getIpAddress());
- }
- // 打开WIFI
- public void openWifi() {
- if (!mWifiManager.isWifiEnabled()) {
- mWifiManager.setWifiEnabled(true);
- }
- }
- // 关闭WIFI
- public void closeWifi() {
- if (mWifiManager.isWifiEnabled()) {
- mWifiManager.setWifiEnabled(false);
- }
- }
- public abstract Intent myRegisterReceiver(BroadcastReceiver receiver, IntentFilter filter);
- public abstract void myUnregisterReceiver(BroadcastReceiver receiver);
- public abstract void onNotifyWifiConnected();
- public abstract void onNotifyWifiConnectFailed();
- // 添加一个网络并连接
- public void addNetwork(WifiConfiguration wcg) {
- register();
- WifiApAdmin.closeWifiAp(mContext);
- int wcgID = mWifiManager.addNetwork(wcg);
- boolean b = mWifiManager.enableNetwork(wcgID, true);
- }
- public static final int TYPE_NO_PASSWD = 0x11;
- public static final int TYPE_WEP = 0x12;
- public static final int TYPE_WPA = 0x13;
- public void addNetwork(String ssid, String passwd, int type) {
- if (ssid == null || passwd == null || ssid.equals("")) {
- Log.e(TAG, "addNetwork() ## nullpointer error!");
- return;
- }
- if (type != TYPE_NO_PASSWD && type != TYPE_WEP && type != TYPE_WPA) {
- Log.e(TAG, "addNetwork() ## unknown type = " + type);
- }
- stopTimer();
- unRegister();
- addNetwork(createWifiInfo(ssid, passwd, type));
- }
- private BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- // TODO Auto-generated method stub
- if (intent.getAction().equals(WifiManager.RSSI_CHANGED_ACTION)) {
- Log.d(TAG, "RSSI changed");
- //有可能是正在获取,或者已经获取了
- Log.d(TAG, " intent is " + WifiManager.RSSI_CHANGED_ACTION);
- if (isWifiContected(mContext) == WIFI_CONNECTED) {
- stopTimer();
- onNotifyWifiConnected();
- unRegister();
- } else if (isWifiContected(mContext) == WIFI_CONNECT_FAILED) {
- stopTimer();
- closeWifi();
- onNotifyWifiConnectFailed();
- unRegister();
- } else if (isWifiContected(mContext) == WIFI_CONNECTING) {
- }
- }
- }
- };
- private final int STATE_REGISTRING = 0x01;
- private final int STATE_REGISTERED = 0x02;
- private final int STATE_UNREGISTERING = 0x03;
- private final int STATE_UNREGISTERED = 0x04;
- private int mHaveRegister = STATE_UNREGISTERED;
- private synchronized void register() {
- Log.v(TAG, "register() ##mHaveRegister = " + mHaveRegister);
- if (mHaveRegister == STATE_REGISTRING
- || mHaveRegister == STATE_REGISTERED) {
- return ;
- }
- mHaveRegister = STATE_REGISTRING;
- myRegisterReceiver(mBroadcastReceiver, new IntentFilter(WifiManager.RSSI_CHANGED_ACTION));
- mHaveRegister = STATE_REGISTERED;
- startTimer();
- }
- private synchronized void unRegister() {
- Log.v(TAG, "unRegister() ##mHaveRegister = " + mHaveRegister);
- if (mHaveRegister == STATE_UNREGISTERED
- || mHaveRegister == STATE_UNREGISTERING) {
- return ;
- }
- mHaveRegister = STATE_UNREGISTERING;
- myUnregisterReceiver(mBroadcastReceiver);
- mHaveRegister = STATE_UNREGISTERED;
- }
- private Timer mTimer = null;
- private void startTimer() {
- if (mTimer != null) {
- stopTimer();
- }
- mTimer = new Timer(true);
- // mTimer.schedule(mTimerTask, 0, 20 * 1000);// 20s
- mTimer.schedule(mTimerTask, 30 * 1000);
- }
- private TimerTask mTimerTask = new TimerTask() {
- @Override
- public void run() {
- // TODO Auto-generated method stub
- Log.e(TAG, "timer out!");
- onNotifyWifiConnectFailed();
- unRegister();
- }
- };
- private void stopTimer() {
- if (mTimer != null) {
- mTimer.cancel();
- mTimer = null;
- }
- }
- @Override
- protected void finalize() {
- try {
- super.finalize();
- unRegister();
- } catch (Throwable e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- public WifiConfiguration createWifiInfo(String SSID, String password, int type) {
- Log.v(TAG, "SSID = " + SSID + "## Password = " + password + "## Type = " + type);
- WifiConfiguration config = new WifiConfiguration();
- config.allowedAuthAlgorithms.clear();
- config.allowedGroupCiphers.clear();
- config.allowedKeyManagement.clear();
- config.allowedPairwiseCiphers.clear();
- config.allowedProtocols.clear();
- config.SSID = "\"" + SSID + "\"";
- WifiConfiguration tempConfig = this.IsExsits(SSID);
- if (tempConfig != null) {
- mWifiManager.removeNetwork(tempConfig.networkId);
- }
- // 分为三种情况:1没有密码2用wep加密3用wpa加密
- if (type == TYPE_NO_PASSWD) {// WIFICIPHER_NOPASS
- config.wepKeys[0] = "";
- config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);
- config.wepTxKeyIndex = 0;
- } else if (type == TYPE_WEP) { // WIFICIPHER_WEP
- config.hiddenSSID = true;
- config.wepKeys[0] = "\"" + password + "\"";
- config.allowedAuthAlgorithms
- .set(WifiConfiguration.AuthAlgorithm.SHARED);
- config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP);
- config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);
- config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP40);
- config.allowedGroupCiphers
- .set(WifiConfiguration.GroupCipher.WEP104);
- config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);
- config.wepTxKeyIndex = 0;
- } else if (type == TYPE_WPA) { // WIFICIPHER_WPA
- config.preSharedKey = "\"" + password + "\"";
- config.hiddenSSID = true;
- config.allowedAuthAlgorithms
- .set(WifiConfiguration.AuthAlgorithm.OPEN);
- config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);
- config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK);
- config.allowedPairwiseCiphers
- .set(WifiConfiguration.PairwiseCipher.TKIP);
- // config.allowedProtocols.set(WifiConfiguration.Protocol.WPA);
- config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP);
- config.allowedPairwiseCiphers
- .set(WifiConfiguration.PairwiseCipher.CCMP);
- config.status = WifiConfiguration.Status.ENABLED;
- }
- return config;
- }
- public static final int WIFI_CONNECTED = 0x01;
- public static final int WIFI_CONNECT_FAILED = 0x02;
- public static final int WIFI_CONNECTING = 0x03;
- /**
- * 判断wifi是否连接成功,不是network
- *
- * @param context
- * @return
- */
- public int isWifiContected(Context context) {
- ConnectivityManager connectivityManager = (ConnectivityManager) context
- .getSystemService(Context.CONNECTIVITY_SERVICE);
- NetworkInfo wifiNetworkInfo = connectivityManager
- .getNetworkInfo(ConnectivityManager.TYPE_WIFI);
- Log.v(TAG, "isConnectedOrConnecting = " + wifiNetworkInfo.isConnectedOrConnecting());
- Log.d(TAG, "wifiNetworkInfo.getDetailedState() = " + wifiNetworkInfo.getDetailedState());
- if (wifiNetworkInfo.getDetailedState() == DetailedState.OBTAINING_IPADDR
- || wifiNetworkInfo.getDetailedState() == DetailedState.CONNECTING) {
- return WIFI_CONNECTING;
- } else if (wifiNetworkInfo.getDetailedState() == DetailedState.CONNECTED) {
- return WIFI_CONNECTED;
- } else {
- Log.d(TAG, "getDetailedState() == " + wifiNetworkInfo.getDetailedState());
- return WIFI_CONNECT_FAILED;
- }
- }
- private WifiConfiguration IsExsits(String SSID) {
- List<WifiConfiguration> existingConfigs = mWifiManager.getConfiguredNetworks();
- for (WifiConfiguration existingConfig : existingConfigs) {
- if (existingConfig.SSID.equals("\"" + SSID + "\"") /*&& existingConfig.preSharedKey.equals("\"" + password + "\"")*/) {
- return existingConfig;
- }
- }
- return null;
- }
- // 断开指定ID的网络
- public void disconnectWifi(int netId) {
- mWifiManager.disableNetwork(netId);
- mWifiManager.disconnect();
- }
- // 检查当前WIFI状态
- public int checkState() {
- return mWifiManager.getWifiState();
- }
- // 锁定WifiLock
- public void acquireWifiLock() {
- mWifiLock.acquire();
- }
- // 解锁WifiLock
- public void releaseWifiLock() {
- // 判断时候锁定
- if (mWifiLock.isHeld()) {
- mWifiLock.acquire();
- }
- }
- // 创建一个WifiLock
- public void creatWifiLock() {
- mWifiLock = mWifiManager.createWifiLock("Test");
- }
- // 得到配置好的网络
- public List<WifiConfiguration> getConfiguration() {
- return mWifiConfiguration;
- }
- // 指定配置好的网络进行连接
- public void connectConfiguration(int index) {
- // 索引大于配置好的网络索引返回
- if (index > mWifiConfiguration.size()) {
- return;
- }
- // 连接配置好的指定ID的网络
- mWifiManager.enableNetwork(mWifiConfiguration.get(index).networkId,
- true);
- }
- public void startScan() {
- mWifiManager.startScan();
- mWifiList = mWifiManager.getScanResults();
- mWifiConfiguration = mWifiManager.getConfiguredNetworks();
- }
- // 得到网络列表
- public List<ScanResult> getWifiList() {
- return mWifiList;
- }
- // 查看扫描结果
- public StringBuilder lookUpScan() {
- StringBuilder stringBuilder = new StringBuilder();
- for (int i = 0; i < mWifiList.size(); i++) {
- stringBuilder
- .append("Index_" + new Integer(i + 1).toString() + ":");
- // 将ScanResult信息转换成一个字符串包
- // 其中把包括:BSSID、SSID、capabilities、frequency、level
- stringBuilder.append((mWifiList.get(i)).toString());
- stringBuilder.append("/n");
- }
- return stringBuilder;
- }
- // 得到MAC地址
- public String getMacAddress() {
- return (mWifiInfo == null) ? "NULL" : mWifiInfo.getMacAddress();
- }
- // 得到接入点的BSSID
- public String getBSSID() {
- return (mWifiInfo == null) ? "NULL" : mWifiInfo.getBSSID();
- }
- // 得到IP地址
- public int getIPAddress() {
- return (mWifiInfo == null) ? 0 : mWifiInfo.getIpAddress();
- }
- // 得到连接的ID
- public int getNetworkId() {
- return (mWifiInfo == null) ? 0 : mWifiInfo.getNetworkId();
- }
- // 得到WifiInfo的所有信息包
- public String getWifiInfo() {
- return (mWifiInfo == null) ? "NULL" : mWifiInfo.toString();
- }
- }
WifiApAdmin.java
参考了 http://blog.csdn.net/cxlmax/article/details/7827102
- package com.widget.hotspot;
- import java.lang.reflect.InvocationTargetException;
- import java.lang.reflect.Method;
- import java.util.Timer;
- import java.util.TimerTask;
- import android.content.Context;
- import android.net.wifi.WifiConfiguration;
- import android.net.wifi.WifiManager;
- import android.util.Log;
- /**
- * 创建热点
- *
- */
- public class WifiApAdmin {
- public static final String TAG = "WifiApAdmin";
- public static void closeWifiAp(Context context) {
- WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
- closeWifiAp(wifiManager);
- }
- private WifiManager mWifiManager = null;
- private Context mContext = null;
- public WifiApAdmin(Context context) {
- mContext = context;
- mWifiManager = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE);
- closeWifiAp(mWifiManager);
- }
- private String mSSID = "";
- private String mPasswd = "";
- public void startWifiAp(String ssid, String passwd) {
- mSSID = ssid;
- mPasswd = passwd;
- if (mWifiManager.isWifiEnabled()) {
- mWifiManager.setWifiEnabled(false);
- }
- stratWifiAp();
- MyTimerCheck timerCheck = new MyTimerCheck() {
- @Override
- public void doTimerCheckWork() {
- // TODO Auto-generated method stub
- if (isWifiApEnabled(mWifiManager)) {
- Log.v(TAG, "Wifi enabled success!");
- this.exit();
- } else {
- Log.v(TAG, "Wifi enabled failed!");
- }
- }
- @Override
- public void doTimeOutWork() {
- // TODO Auto-generated method stub
- this.exit();
- }
- };
- timerCheck.start(15, 1000);
- }
- public void stratWifiAp() {
- Method method1 = null;
- try {
- method1 = mWifiManager.getClass().getMethod("setWifiApEnabled",
- WifiConfiguration.class, boolean.class);
- WifiConfiguration netConfig = new WifiConfiguration();
- netConfig.SSID = mSSID;
- netConfig.preSharedKey = mPasswd;
- netConfig.allowedAuthAlgorithms
- .set(WifiConfiguration.AuthAlgorithm.OPEN);
- netConfig.allowedProtocols.set(WifiConfiguration.Protocol.RSN);
- netConfig.allowedProtocols.set(WifiConfiguration.Protocol.WPA);
- netConfig.allowedKeyManagement
- .set(WifiConfiguration.KeyMgmt.WPA_PSK);
- netConfig.allowedPairwiseCiphers
- .set(WifiConfiguration.PairwiseCipher.CCMP);
- netConfig.allowedPairwiseCiphers
- .set(WifiConfiguration.PairwiseCipher.TKIP);
- netConfig.allowedGroupCiphers
- .set(WifiConfiguration.GroupCipher.CCMP);
- netConfig.allowedGroupCiphers
- .set(WifiConfiguration.GroupCipher.TKIP);
- method1.invoke(mWifiManager, netConfig, true);
- } catch (IllegalArgumentException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IllegalAccessException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (InvocationTargetException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (SecurityException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (NoSuchMethodException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- private static void closeWifiAp(WifiManager wifiManager) {
- if (isWifiApEnabled(wifiManager)) {
- try {
- Method method = wifiManager.getClass().getMethod("getWifiApConfiguration");
- method.setAccessible(true);
- WifiConfiguration config = (WifiConfiguration) method.invoke(wifiManager);
- Method method2 = wifiManager.getClass().getMethod("setWifiApEnabled", WifiConfiguration.class, boolean.class);
- method2.invoke(wifiManager, config, false);
- } catch (NoSuchMethodException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IllegalArgumentException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IllegalAccessException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (InvocationTargetException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- }
- private static boolean isWifiApEnabled(WifiManager wifiManager) {
- try {
- Method method = wifiManager.getClass().getMethod("isWifiApEnabled");
- method.setAccessible(true);
- return (Boolean) method.invoke(wifiManager);
- } catch (NoSuchMethodException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (Exception e) {
- e.printStackTrace();
- }
- return false;
- }
- }
MyTimeCheck.java
- package com.widget.hotspot;
- public abstract class MyTimerCheck {
- private int mCount = 0;
- private int mTimeOutCount = 1;
- private int mSleepTime = 1000; // 1s
- private boolean mExitFlag = false;
- private Thread mThread = null;
- /**
- * Do not process UI work in this.
- */
- public abstract void doTimerCheckWork();
- public abstract void doTimeOutWork();
- public MyTimerCheck() {
- mThread = new Thread(new Runnable() {
- @Override
- public void run() {
- // TODO Auto-generated method stub
- while (!mExitFlag) {
- mCount++;
- if (mCount < mTimeOutCount) {
- doTimerCheckWork();
- try {
- mThread.sleep(mSleepTime);
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- exit();
- }
- } else {
- doTimeOutWork();
- }
- }
- }
- });
- }
- /**
- * start
- * @param times How many times will check?
- * @param sleepTime ms, Every check sleep time.
- */
- public void start(int timeOutCount, int sleepTime) {
- mTimeOutCount = timeOutCount;
- mSleepTime = sleepTime;
- mThread.start();
- }
- public void exit() {
- mExitFlag = true;
- }
- }
xml布局简单不上了,
效果自己试试看打印就知道了
Android 连接Wifi和创建Wifi热点 demo的更多相关文章
- android 代码设置、打开wifi热点及热点的连接
用过快牙的朋友应该知道它们在两天设备之间传输文件的时候使用的是wifi热点,然后另一台便连接这个热点再进行传输.快牙传输速度惊人应该跟它的这种机制有关系吧.不知道它的搜索机制是怎样的,但我想应该可以通 ...
- ubuntu创建wifi热点(android可识别)亲测可用
转自http://jingyan.baidu.com/article/ea24bc39b03fc6da62b331f0.html 如何在ubuntu系统下创建android可识别热点?一般环境下创建的 ...
- Android 开发 创建WiFi、WiFi热点 ---开发集合
WIFI 权限 <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /> < ...
- android 代码设置、打开wifi热点及热点的连接(转)
用过快牙的朋友应该知道它们在两天设备之间传输文件的时候使用的是wifi热点,然后另一台便连接这个热点再进行传输.快牙传输速度惊人应该跟它的这种机制有关系吧.不知道它的搜索机制是怎样的,但我想应该可 ...
- 关于 win10 创建WiFi热点 问题(无法启动承载网络 , 我们无法设置移动热点,因为你的电脑未建立以太网,wifi或手机网络数据连接 )
电脑创建WiFi,一般三种办法: 1. WiFi共享软件:猎豹wifi.wifi共享精灵.wifi共享大师..... 2. 命令提示符 netsh wlan set hostednetwork mod ...
- Android开发之扫描附近wifi热点并列表显示
近期项目中用到了wifi模块.今天做一个简单的总结. 參考:http://www.2cto.com/kf/201310/253617.html 1.如何获取wifi对象并进行操作 要操作WIFI设备, ...
- Windows 7/8 创建WIFI热点
问题描述:很多人(特别是中国的大学生)都拥有一台联网的笔记本电脑,而手机使用的却是电信运营商提供的限制数量和速度的GPRS. 很多人不敢想象:联网的笔记本电脑能够将其流量以WiFi的形式共享出来供其它 ...
- Android 6.0 中的 Wifi 连接
Android 6.0 中的 Wifi 连接 这几天在写一个软件,结果被其中的 wifi 连接问题困扰了 3 天. 先描述下需求: usb 接口接了一根 usb2serial,通过这个接口接收命令 当 ...
- android 连接wifi案例
1.xml布局文件: <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmln ...
随机推荐
- JavaScript_object基础
之前写Java时老是有点蒙,大部分都是用jQuery,但原理还不是很清楚,最近一段时间在系统的学习JavaScript,有什么问题或错误请指出,多谢..................... Obje ...
- UITextField AutoComplete iOS输入框内文本自动完成
当你打开Safari的时候,输入网址,会有许多候选网址,点击后,自动填充到输入框,进入网页. 打开词典查单词的时候,输入前面部分字母,软件会给出符合的候选单词. 这样做的目的,是为了省去用户繁琐的输入 ...
- MVC之序列化
1.AdminUserInfo.cs [Serializable]序列化类——System.SerializableAttribute 串行化是指存储和获取磁盘文件.内存或其他地方中的对象.在串行化时 ...
- 较详细的sqlserver数据库备份、恢复(转)
C#实现SQL数据库备份与恢复 有两种方法,都是保存为.bak文件.一种是直接用Sql语句执行,另一种是通过引用SQL Server的SQLDMO组件来实现: .通过执行Sql语句来实现 注意,用Sq ...
- JQUERY1.9学习笔记 之基本过滤器(九) 小于选择器
小于选择器 jQuery( ":lt(index)" ) jQuery( ":lt(-index)" ) 描述:选择所有小于指定下标的元素. <!DOCT ...
- 【行为型】Mediator模式
中介者模式目的是将对象间的交互封装在一个对象中,从而使用各对象间的相互依赖解耦,并可以独立更改对像间的交互.在实际项目开发过程中,因某些原因(如:业务逻辑处理不当或设计不当等)使得多个不同对象间需要相 ...
- 折半插入排序(Binary Insertion Sort)的C语言实现
原创文章,转载请注明来自钢铁侠Mac博客http://www.cnblogs.com/gangtiexia 折半插入排序(Binary Insertion Sort)的基本思想是将新记录插入到已经 ...
- hdu1003 Max Sum(经典dp )
A - 最大子段和 Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Descr ...
- 在同个工程中使用 Swift 和 Objective-C(Swift 2.0更新)-b
本节包含内容: Mix and Match 概述(Mix and Match Overview) 在同个应用的 target 中导入(Importing Code from Within the Sa ...
- C 编译器错误信息中文翻译
Ambiguous operators need parentheses 不 明确的运算需要用括号括起 Ambiguous symbol ``xxx`` 不明确的符号 Argument list sy ...