青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

posts - 12,  comments - 21,  trackbacks - 0
今天照著書上做打開和關閉WIFI的小例子練習,最后在模擬器上運行出現(xiàn)了問題,就是無法打開,""the application has stopped unexpectedly.please try again"
代碼是按書上寫的應該沒有問題.幫忙看看...
  1 package com.ex29;
  2 
  3 import android.app.Activity;
  4 import android.content.Context;
  5 import android.net.wifi.WifiManager;
  6 import android.os.Bundle;
  7 import android.util.Log;
  8 import android.view.View;
  9 import android.view.View.OnClickListener;
 10 import android.widget.CheckBox;
 11 import android.widget.TextView;
 12 import android.widget.Toast;
 13 
 14 public class ex29 extends Activity {
 15     private TextView myTextView;
 16     private CheckBox myCheckBox;
 17     // 創(chuàng)建WifiManager對象
 18     private WifiManager mWifiManager01;
 19 
 20     /** Called when the activity is first created. */
 21     @Override
 22     public void onCreate(Bundle savedInstanceState) {
 23         super.onCreate(savedInstanceState);
 24         setContentView(R.layout.main);
 25 
 26         myTextView = (TextView) findViewById(R.id.mTextView);
 27         myCheckBox = (CheckBox) findViewById(R.id.mCheckbox);
 28         // 以getSystemService取得WIFI_SERVICE
 29         mWifiManager01 = (WifiManager) this
 30                 .getSystemService(Context.WIFI_SERVICE);
 31 
 32         // 判斷運行程序后WIFI是否打開或打開中
 33         if (mWifiManager01.isWifiEnabled()) {
 34             if (mWifiManager01.getWifiState() == WifiManager.WIFI_STATE_ENABLED) {
 35                 myCheckBox.setChecked(true);
 36                 myCheckBox.setText(R.string.str_unchecked);
 37             } else {
 38                 myCheckBox.setChecked(false);
 39                 myCheckBox.setText(R.string.str_checked);
 40             }
 41 
 42             // 捕捉CheckBox的單擊事件
 43             myCheckBox.setOnClickListener(new OnClickListener() {
 44 
 45                 @Override
 46                 public void onClick(View v) {
 47                     // TODO Auto-generated method stub
 48                     // 當選取項為取消選取狀態(tài)
 49                     if (myCheckBox.isChecked() == false) {
 50                         // 嘗試關閉wifi服務
 51                         try {
 52                             // 判斷Wifi狀態(tài)是否為已打開
 53                             if (mWifiManager01.isWifiEnabled()) {
 54                                 // 關閉Wifi
 55                                 if (mWifiManager01.setWifiEnabled(false)) {
 56                                     myTextView
 57                                             .setText(R.string.str_stop_wifi_done);
 58                                 } else {
 59                                     myTextView
 60                                             .setText(R.string.str_stop_wifi_failed);
 61                                 }
 62                             } else {
 63                                 // wifi狀態(tài)不為已打開狀態(tài)
 64                                 switch (mWifiManager01.getWifiState()) {
 65                                 case WifiManager.WIFI_STATE_ENABLING:
 66                                     myTextView
 67                                             .setText(getResources()
 68                                                     .getText(
 69                                                             R.string.str_stop_wifi_failed)
 70                                                     + ":"
 71                                                     + getResources()
 72                                                             .getText(
 73                                                                     R.string.str_wifi_enabling));
 74                                     break;
 75                                 case WifiManager.WIFI_STATE_DISABLING:
 76                                     myTextView
 77                                             .setText(getResources()
 78                                                     .getText(
 79                                                             R.string.str_stop_wifi_failed)
 80                                                     + ":"
 81                                                     + getResources()
 82                                                             .getText(
 83                                                                     R.string.str_wifi_diabling));
 84                                     break;
 85                                 case WifiManager.WIFI_STATE_DISABLED:
 86                                     myTextView.setText(getResources().getText(
 87                                             R.string.str_stop_wifi_failed)
 88                                             + ":"
 89                                             + getResources().getText(
 90                                                     R.string.str_wifi_diabled));
 91                                     break;
 92                                 case WifiManager.WIFI_STATE_UNKNOWN:
 93                                 default:
 94                                     myTextView.setText(getResources().getText(
 95                                             R.string.str_stop_wifi_failed)
 96                                             + ":"
 97                                             + getResources().getText(
 98                                                     R.string.str_wifi_unknow));
 99                                     break;
100                                 }
101                                 myCheckBox.setText(R.string.str_checked);
102                             }
103                         } catch (Exception e) {
104                             Log.i("HIPPO", e.toString());
105                         }
106                     } else if (myCheckBox.isChecked() == true) {
107                         // 嘗試打開WIFi服務
108                         try {
109                             if (!mWifiManager01.isWifiEnabled()
110                                     && mWifiManager01.getWifiState() != WifiManager.WIFI_STATE_ENABLING) {
111                                 if (mWifiManager01.setWifiEnabled(true)) {
112                                     switch (mWifiManager01.getWifiState()) {
113                                     case WifiManager.WIFI_STATE_ENABLING:
114                                         myTextView
115                                                 .setText(getResources()
116                                                         .getText(
117                                                                 R.string.str_wifi_enabling));
118                                         break;
119                                     case WifiManager.WIFI_STATE_ENABLED:
120                                         myTextView
121                                                 .setText(getResources()
122                                                         .getText(
123                                                                 R.string.str_start_wifi_done));
124                                         break;
125                                     default:
126                                         myTextView
127                                                 .setText(getResources()
128                                                         .getText(
129                                                                 R.string.str_start_wifi_failed)
130                                                         + ":"
131                                                         + getResources()
132                                                                 .getText(
133                                                                         R.string.str_wifi_unknow));
134                                         break;
135                                     }
136                                 } else {
137                                     myTextView
138                                             .setText(R.string.str_start_wifi_failed);
139                                 }
140                             } else {
141                                 switch (mWifiManager01.getWifiState()) {
142                                 case WifiManager.WIFI_STATE_ENABLING:
143                                     myTextView
144                                             .setText(getResources()
145                                                     .getText(
146                                                             R.string.str_start_wifi_failed)
147                                                     + ":"
148                                                     + getResources()
149                                                             .getText(
150                                                                     R.string.str_wifi_enabling));
151                                     break;
152                                 case WifiManager.WIFI_STATE_DISABLING:
153                                     myTextView
154                                             .setText(getResources()
155                                                     .getText(
156                                                             R.string.str_start_wifi_failed)
157                                                     + ":"
158                                                     + getResources()
159                                                             .getText(
160                                                                     R.string.str_wifi_diabling));
161                                     break;
162                                 case WifiManager.WIFI_STATE_DISABLED:
163                                     myTextView.setText(getResources().getText(
164                                             R.string.str_start_wifi_failed)
165                                             + ":"
166                                             + getResources().getText(
167                                                     R.string.str_wifi_diabled));
168                                     break;
169                                 case WifiManager.WIFI_STATE_UNKNOWN:
170                                 default:
171                                     myTextView.setText(getResources().getText(
172                                             R.string.str_start_wifi_failed)
173                                             + ":"
174                                             + getResources().getText(
175                                                     R.string.str_wifi_unknow));
176                                     break;
177                                 }
178                             }
179                             myCheckBox.setText(R.string.str_unchecked);
180                         } catch (Exception e) {
181                             Log.i("HIPPO", e.toString());
182                             e.printStackTrace();
183                         }
184                     }
185 
186                 }
187 
188             });
189         }
190 
191     }
192 
193     public void mMakeTextToast(String str, boolean isLong) {
194         if (isLong == true) {
195             Toast.makeText(ex29.this, str, Toast.LENGTH_LONG).show();
196         } else {
197             Toast.makeText(ex29.this, str, Toast.LENGTH_SHORT).show();
198         }
199     }
200 
201     @Override
202     protected void onResume() {
203         // TODO Auto-generated method stub
204         try {
205             switch (mWifiManager01.getWifiState()) {
206             case WifiManager.WIFI_STATE_ENABLING:
207                 myTextView.setText(getResources().getText(
208                         R.string.str_wifi_enabling));
209                 break;
210             case WifiManager.WIFI_STATE_ENABLED:
211                 myTextView.setText(getResources().getText(
212                         R.string.str_wifi_enabled));
213                 break;
214             case WifiManager.WIFI_STATE_DISABLING:
215                 myTextView.setText(getResources().getText(
216                         R.string.str_wifi_diabling));
217                 break;
218             case WifiManager.WIFI_STATE_DISABLED:
219                 myTextView.setText(getResources().getText(
220                         R.string.str_wifi_diabled));
221                 break;
222             case WifiManager.WIFI_STATE_UNKNOWN:
223             default:
224                 myTextView.setText(getResources().getText(
225                         R.string.str_wifi_unknow));
226                 break;
227             }
228         } catch (Exception e) {
229             myTextView.setText(e.toString());
230             e.getStackTrace();
231         }
232 
233         super.onResume();
234     }
235 
236     @Override
237     protected void onPause() {
238         // TODO Auto-generated method stub
239         super.onPause();
240     }
241 
242 }


posted on 2011-06-25 15:51 DoubleW 閱讀(2578) 評論(0)  編輯 收藏 引用

只有注冊用戶登錄后才能發(fā)表評論。
網(wǎng)站導航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


<2011年5月>
24252627282930
1234567
891011121314
15161718192021
22232425262728
2930311234

常用鏈接

留言簿(3)

隨筆檔案(12)

文章檔案(2)

最新隨筆

搜索

  •  

積分與排名

  • 積分 - 29419
  • 排名 - 665

最新隨筆

最新評論

閱讀排行榜

評論排行榜

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            尤物精品在线| 久久午夜国产精品| 久久国产综合精品| 伊人久久婷婷色综合98网| 久久精品国产一区二区三区免费看| 久久字幕精品一区| 最新中文字幕一区二区三区| 欧美伦理影院| 午夜欧美不卡精品aaaaa| 久久全球大尺度高清视频| 最近中文字幕日韩精品| 国产精品v亚洲精品v日韩精品 | 欧美精品激情在线观看| 99精品视频一区| 久久久夜精品| aaa亚洲精品一二三区| 国产精品一区二区欧美| 麻豆成人在线观看| 一区二区国产在线观看| 久久久久久久一区二区| 日韩视频一区| 国产亚洲精品美女| 欧美片第一页| 久久久久高清| 亚洲调教视频在线观看| 欧美波霸影院| 欧美亚洲视频一区二区| 亚洲日本久久| 国产在线不卡精品| 欧美午夜视频网站| 乱码第一页成人| 亚洲欧美自拍偷拍| 91久久久久久| 老司机一区二区| 先锋影音久久久| 在线视频中文亚洲| 亚洲国产高清在线| 国产午夜精品一区二区三区欧美| 欧美国产日韩一区二区三区| 欧美在线一区二区三区| 夜夜爽夜夜爽精品视频| 欧美大片va欧美在线播放| 久久国产精品99久久久久久老狼| 日韩一本二本av| 亚洲国产一区二区三区a毛片| 国产人成精品一区二区三| 国产精品v欧美精品∨日韩| 欧美电影在线观看完整版| 欧美一区国产二区| 亚洲一二三四久久| 99在线精品免费视频九九视| 亚洲激情在线激情| 欧美大片在线观看| 久久中文久久字幕| 久久免费99精品久久久久久| 欧美在线首页| 午夜影院日韩| 欧美亚洲综合另类| 亚洲一区二区影院| 宅男噜噜噜66一区二区| 亚洲精品一区二区在线| 在线看片欧美| 在线欧美小视频| 在线观看日产精品| 在线观看一区欧美| 亚洲成人直播| 亚洲级视频在线观看免费1级| 精品91在线| 亚洲电影免费观看高清完整版在线 | 免费视频一区| 欧美不卡一卡二卡免费版| 久色成人在线| 麻豆91精品| 欧美激情视频一区二区三区免费| 欧美国产91| 亚洲高清不卡av| 91久久夜色精品国产九色| 91久久夜色精品国产网站| 亚洲三级电影全部在线观看高清| 亚洲国产精品v| 亚洲毛片在线免费观看| 一区二区三区高清不卡| 亚洲男人第一网站| 欧美一区二区三区在线观看视频| 久久久999精品视频| 久久久久久穴| 欧美成人久久| 国产精品久久二区| 国产日韩欧美精品在线| 精久久久久久久久久久| 亚洲娇小video精品| 一本一本a久久| 性亚洲最疯狂xxxx高清| 久久久久久尹人网香蕉| 欧美成人在线免费视频| 亚洲乱码国产乱码精品精天堂| 亚洲网站在线| 久久久av网站| 欧美日韩裸体免费视频| 国产欧美一区二区三区久久人妖| 亚洲成色最大综合在线| 夜夜嗨av一区二区三区| 欧美专区福利在线| 欧美激情精品久久久久| 亚洲最黄网站| 久久久最新网址| 欧美性大战久久久久久久| 国产一区在线播放| 亚洲毛片网站| 久久久久久一区二区| 亚洲美女精品一区| 欧美一区影院| 欧美人交a欧美精品| 国产自产女人91一区在线观看| 亚洲精品资源美女情侣酒店| 欧美一级播放| 亚洲精品视频免费观看| 欧美综合国产| 国产精品国产三级国产aⅴ无密码 国产精品国产三级国产aⅴ入口 | 欧美成人影音| 亚洲欧美激情四射在线日| 另类尿喷潮videofree| 国产精品欧美在线| 亚洲国产成人精品女人久久久 | 欧美亚洲成人网| 亚洲国产精品电影| 欧美一区二区高清在线观看| 亚洲韩国精品一区| 欧美伊人影院| 国产精品国产亚洲精品看不卡15 | 一区二区三区黄色| 麻豆视频一区二区| 亚洲欧美日韩精品| 欧美日韩亚洲一区二区三区在线 | 中文成人激情娱乐网| 免费一级欧美片在线播放| 亚洲欧洲99久久| 欧美日韩亚洲免费| 亚洲美女视频在线观看| 麻豆久久婷婷| 久久久99免费视频| 国产亚洲在线| 欧美在线www| 亚洲婷婷综合色高清在线| 欧美人交a欧美精品| 亚洲精品综合| 欧美激情一区二区三区蜜桃视频| 欧美在线播放| 国产日韩欧美在线观看| 性伦欧美刺激片在线观看| 在线亚洲免费| 国产精品国产三级国产普通话蜜臀 | 亚洲婷婷在线| 亚洲美女在线观看| 欧美国产一区视频在线观看| 91久久国产综合久久蜜月精品 | 136国产福利精品导航网址| 久久精品国产欧美亚洲人人爽| 亚洲一区二区在| 国产精品视频观看| 欧美一级片一区| 亚洲欧美日韩区| 国产午夜久久| 久久女同互慰一区二区三区| 久久久久在线观看| 亚洲国产视频一区| 欧美激情在线狂野欧美精品| 欧美国产在线视频| 亚洲老板91色精品久久| 亚洲精品久久久一区二区三区| 欧美精品国产精品| 亚洲午夜精品久久| 亚洲一区二区三区777| 国产精品你懂的在线欣赏| 欧美影院视频| 久久久噜噜噜久噜久久| 亚洲国产日韩欧美| 亚洲日本欧美| 国产精品午夜在线观看| 久久九九精品| 免费在线日韩av| 亚洲手机成人高清视频| 亚洲在线观看免费视频| 激情六月婷婷久久| 91久久精品国产91久久性色| 欧美涩涩网站| 久久久久国产精品厨房| 欧美 日韩 国产在线| 在线中文字幕一区| 性色一区二区| 最新亚洲一区| 亚洲欧美成人一区二区三区| 一色屋精品视频在线观看网站| 亚洲国产日韩综合一区| 国产精品久久久久国产精品日日| 久久蜜桃av一区精品变态类天堂| 欧美韩日一区| 久久精品一区二区| 欧美福利电影网| 久久国产直播|