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

posts - 12,  comments - 21,  trackbacks - 0
今天照著書上做打開和關閉WIFI的小例子練習,最后在模擬器上運行出現了問題,就是無法打開,""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     // 創建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                     // 當選取項為取消選取狀態
 49                     if (myCheckBox.isChecked() == false) {
 50                         // 嘗試關閉wifi服務
 51                         try {
 52                             // 判斷Wifi狀態是否為已打開
 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狀態不為已打開狀態
 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)  編輯 收藏 引用

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


<2011年6月>
2930311234
567891011
12131415161718
19202122232425
262728293012
3456789

常用鏈接

留言簿(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>
            亚洲国产精品va在线看黑人 | 久久精品国产久精国产一老狼| 欧美高清日韩| 国产精品大全| 亚洲美女视频| 亚洲精品久久久久| 久久久久免费观看| 久久精品国产一区二区三| 国产精品扒开腿做爽爽爽软件| 欧美二区在线观看| 激情综合色综合久久综合| 亚洲欧美成人网| 亚洲一品av免费观看| 欧美精品二区| 亚洲国产欧美另类丝袜| 亚洲福利免费| 免费视频一区| 欧美777四色影视在线| 国内精品国语自产拍在线观看| 亚洲无线一线二线三线区别av| 日韩视频在线观看国产| 欧美区高清在线| 亚洲福利视频一区二区| 亚洲黄色av| 欧美福利电影网| 亚洲成人资源网| 亚洲三级视频在线观看| 欧美黑人在线播放| 99国产精品国产精品久久 | 日韩午夜中文字幕| 欧美国产在线电影| 亚洲另类黄色| 亚洲欧美日韩在线一区| 国产精品亚洲不卡a| 欧美一区二区私人影院日本| 久久精品日韩| 亚洲第一在线综合在线| 免费欧美日韩| 99热精品在线| 午夜久久福利| 一区免费在线| 欧美成人乱码一区二区三区| 日韩西西人体444www| 亚洲男女毛片无遮挡| 国产欧美在线看| 久久久久www| 亚洲国产欧洲综合997久久| 一区二区三区精品视频| 国产精品视频| 久久亚洲欧美国产精品乐播| 91久久精品国产91久久性色tv| 中文亚洲欧美| 国产自产2019最新不卡| 欧美高清在线精品一区| 亚洲素人一区二区| 久久欧美中文字幕| 一区二区不卡在线视频 午夜欧美不卡在 | 亚洲美女黄网| 久久精品五月婷婷| 日韩亚洲欧美在线观看| 国产日产精品一区二区三区四区的观看方式 | 欧美一区二区三区视频在线| 国产亚洲视频在线观看| 久久综合中文色婷婷| 99在线|亚洲一区二区| 久久裸体艺术| 99在线视频精品| 久久久久亚洲综合| 亚洲最快最全在线视频| 国产最新精品精品你懂的| 欧美精品在线免费播放| 欧美在线视频免费| 亚洲免费av片| 女女同性女同一区二区三区91| 一区二区国产精品| 一区二区在线看| 国产精品视频99| 欧美电影资源| 久久精品视频在线播放| 一区二区免费看| 亚洲第一色中文字幕| 久久久精品性| 午夜日韩在线观看| 一本色道久久加勒比88综合| **性色生活片久久毛片| 国产午夜精品视频| 国产精品免费区二区三区观看| 免费人成精品欧美精品| 久久久www| 午夜视频久久久久久| 亚洲免费观看高清完整版在线观看熊| 噜噜噜躁狠狠躁狠狠精品视频 | 亚洲国产精品传媒在线观看 | 一区二区日韩免费看| 亚洲高清在线| 免费日韩av| 久久亚洲精品视频| 久久国产精品99精品国产| 亚洲欧美日韩第一区 | 亚洲乱码国产乱码精品精98午夜 | 亚洲精品女人| 美女视频黄a大片欧美| 欧美影片第一页| 欧美尤物巨大精品爽| 亚洲欧美视频在线观看| 亚洲一区二区在线看| 亚洲综合精品自拍| 亚洲一区二区三区免费视频| 一区二区三区国产在线观看| 国产精品99久久久久久久久久久久 | 欧美日韩精品久久久| 欧美精品aa| 欧美日韩国产在线播放| 欧美日韩一区在线观看| 国产精品国产三级国产专播精品人 | 欧美成人免费全部| 亚洲第一中文字幕在线观看| 亚洲激情视频在线| 亚洲精品色图| 亚洲一区二区欧美日韩| 午夜精品久久99蜜桃的功能介绍| 亚洲欧美电影院| 久久av一区二区三区亚洲| 久久久久久成人| 欧美二区乱c少妇| 欧美日韩一区二区三区在线| 国产精品高精视频免费| 国产欧美韩日| 136国产福利精品导航| 日韩视频中文| 亚洲欧美日韩一区在线观看| 久久久999成人| 亚洲电影视频在线| 一区二区三区视频在线 | 免费欧美视频| 欧美日韩一区二区在线观看| 国产精品蜜臀在线观看| 国产午夜精品麻豆| 亚洲欧洲日本一区二区三区| 亚洲视频免费看| 久久日韩粉嫩一区二区三区| 亚洲第一页中文字幕| 亚洲网站在线播放| 猫咪成人在线观看| 国产精品播放| 亚洲高清资源| 亚洲欧美精品在线观看| 久久综合狠狠综合久久综青草| 亚洲精品美女在线| 欧美亚洲日本一区| 欧美精品七区| 精品av久久707| 亚洲午夜一二三区视频| 免费高清在线视频一区·| 亚洲免费观看高清完整版在线观看熊| 欧美亚洲免费| 国产精品电影网站| 亚洲精品日本| 久久一二三四| 亚洲愉拍自拍另类高清精品| 欧美刺激性大交免费视频| 国产婷婷色一区二区三区在线| 亚洲精品老司机| 久久一区欧美| 亚洲欧美一区二区三区久久| 欧美日韩国产精品一区| 亚洲啪啪91| 蜜臀av性久久久久蜜臀aⅴ四虎| 一道本一区二区| 欧美激情一区二区| 最新国产乱人伦偷精品免费网站| 久久国产精品一区二区三区四区| 99国产欧美久久久精品| 女人天堂亚洲aⅴ在线观看| 国产一二精品视频| 亚洲欧美三级伦理| 一本久道综合久久精品| 欧美激情2020午夜免费观看| 亚洲国产精品t66y| 久久青草欧美一区二区三区| 亚洲欧美日韩专区| 国产精品久久午夜| 99国内精品久久| 亚洲国产精品一区| 欧美.日韩.国产.一区.二区| 激情视频一区二区三区| 另类激情亚洲| 久久久av毛片精品| 一区免费观看视频| 免费人成网站在线观看欧美高清| 久久av红桃一区二区小说| 国产亚洲女人久久久久毛片| 久久精品毛片| 欧美在线一级va免费观看| 国产亚洲精品久久久久久| 久久精品国语| 久久久综合香蕉尹人综合网| 在线观看视频亚洲| 亚洲国产精品尤物yw在线观看| 免费久久99精品国产自|