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

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年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>
            欧美视频在线视频| 欧美一区二区三区电影在线观看| 日韩视频国产视频| 国内自拍一区| 在线视频亚洲一区| 亚洲欧洲在线视频| 久久成人一区| 久久精品中文字幕一区二区三区| 欧美日韩精品一区二区天天拍小说 | 蜜桃精品久久久久久久免费影院| 亚洲综合视频网| 欧美极品一区| 亚洲第一精品夜夜躁人人躁| 国产一区二区黄| 亚洲婷婷在线| 亚洲欧美另类国产| 欧美视频免费在线| 日韩一级片网址| 亚洲精品乱码久久久久久日本蜜臀| 久久精品日产第一区二区| 欧美一区二区视频97| 国产精品一区二区欧美| 亚洲手机视频| 午夜精品福利一区二区三区av | 亚洲精品久久嫩草网站秘色| 久久精品女人| 欧美成ee人免费视频| 亚洲高清色综合| 久久综合伊人77777蜜臀| 蜜臀91精品一区二区三区| 伊人久久大香线蕉综合热线 | 国产精品高清免费在线观看| 亚洲精选中文字幕| 亚洲午夜精品| 国产精品日韩久久久| 亚洲欧美三级伦理| 久久久久国产免费免费| 一区二区在线观看视频| 久久综合久久久久88| 亚洲人成网站在线观看播放| 亚洲视频久久| 国产日本欧美一区二区| 巨乳诱惑日韩免费av| 最新国产精品拍自在线播放| 亚洲综合视频一区| 红桃视频一区| 欧美激情精品久久久久久变态| 亚洲免费激情| 久久精品导航| 亚洲高清视频一区二区| 欧美日本不卡高清| 亚洲你懂的在线视频| 男女av一区三区二区色多| 日韩香蕉视频| 国产亚洲精品一区二区| 欧美aa在线视频| 亚洲免费人成在线视频观看| 久久夜色精品国产欧美乱极品| 亚洲破处大片| 国产精品资源| 欧美mv日韩mv国产网站| 亚洲一区二区精品在线观看| 理论片一区二区在线| 在线视频欧美精品| 狠狠色狠色综合曰曰| 欧美日韩亚洲91| 久久精品视频网| 日韩视频永久免费| 欧美sm视频| 午夜欧美电影在线观看| 亚洲精品国产精品乱码不99按摩| 国产精品网站在线观看| 欧美成人精品福利| 香蕉乱码成人久久天堂爱免费| 亚洲第一主播视频| 久久色在线播放| 亚洲一区二区成人在线观看| 在线看国产一区| 国产精品区一区| 欧美日韩另类丝袜其他| 久久人人爽爽爽人久久久| 亚洲一级黄色片| 亚洲日本va午夜在线影院| 久久久噜噜噜久久中文字幕色伊伊| 夜久久久久久| 亚洲人成7777| 狠狠色综合网站久久久久久久| 欧美日本高清视频| 久久一综合视频| 久久av红桃一区二区小说| 亚洲午夜av在线| 日韩系列欧美系列| 亚洲国产欧美一区二区三区同亚洲 | 久久爱www久久做| 在线亚洲伦理| 亚洲美女视频| 亚洲激情女人| 亚洲国产电影| 欧美jizzhd精品欧美巨大免费| 久久精品亚洲| 久久se精品一区精品二区| 亚洲一区影院| 亚洲一区二区高清| 亚洲婷婷免费| 一区二区国产日产| 亚洲精品视频二区| 亚洲精品一区二区三区婷婷月| 国产一区二区三区在线观看免费| 国产精品男gay被猛男狂揉视频| 欧美日韩中文在线观看| 欧美日韩国产黄| 欧美区视频在线观看| 欧美精品久久99| 欧美精品国产一区二区| 欧美精品系列| 欧美偷拍一区二区| 欧美色综合网| 国产精品一二| 国产婷婷色一区二区三区| 国产综合网站| 亚洲国产欧美日韩精品| 亚洲精品久久久久中文字幕欢迎你| 亚洲欧洲另类国产综合| 亚洲国产日韩欧美在线动漫| 亚洲国产高清高潮精品美女| 亚洲激情视频在线| 99re6这里只有精品| 亚洲午夜激情| 久久久www成人免费无遮挡大片| 老巨人导航500精品| 亚洲大片免费看| 一区二区久久久久| 午夜一区二区三区在线观看| 久久国产精品久久久久久电车| 久久久综合香蕉尹人综合网| 欧美va亚洲va日韩∨a综合色| 欧美紧缚bdsm在线视频| 国产精品久久久久久影院8一贰佰| 国产精品久久久久久模特| 国产一区二区精品丝袜| 亚洲级视频在线观看免费1级| 在线午夜精品| 久久男女视频| 亚洲精品自在在线观看| 午夜国产精品视频| 免费成人av资源网| 国产精品久久久久久久久久免费| 国产在线播放一区二区三区| 亚洲精品视频在线看| 午夜亚洲福利| 欧美国产精品劲爆| 亚洲小视频在线观看| 久久久噜久噜久久综合| 欧美亚州韩日在线看免费版国语版| 国产一区二区三区在线播放免费观看| 亚洲精品无人区| 久久精品人人做人人爽| 亚洲国产91色在线| 久久国产精品网站| 国产精品乱码一区二三区小蝌蚪 | 亚洲欧美国产77777| 你懂的网址国产 欧美| 国产精品乱人伦一区二区 | 免费人成网站在线观看欧美高清| 9国产精品视频| 免费观看不卡av| 国内精品一区二区三区| 亚洲永久免费视频| 欧美高清视频免费观看| 一本久道久久综合婷婷鲸鱼| 久久久久国产精品午夜一区| 亚洲视频你懂的| 欧美精品免费观看二区| 亚洲二区在线视频| 久久久在线视频| 亚洲欧美三级在线| 欧美午夜大胆人体| 亚洲精品影视| 欧美高清在线视频| 久久人人97超碰精品888| 国产人成精品一区二区三| 亚洲一区免费视频| 亚洲人成网站在线观看播放| 欧美一区二视频| 国产精品久久久久久久久久ktv| 亚洲日本国产| 欧美国产高清| 麻豆成人av| 亚洲国产精品t66y| 欧美插天视频在线播放| 久久夜色撩人精品| 亚洲福利久久| 欧美韩国日本综合| 欧美成人亚洲成人日韩成人| 91久久精品一区| 最新成人av网站| 欧美四级在线| 亚洲欧美激情四射在线日| 中国日韩欧美久久久久久久久| 欧美小视频在线|