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

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   管理


<2025年12月>
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910

常用鏈接

留言簿(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在线看黑人| 亚洲欧美日韩区| 亚洲综合激情| 欧美视频观看一区| 亚洲精品免费网站| 亚洲伦理中文字幕| 蜜桃伊人久久| 欧美激情免费观看| 亚洲大胆在线| 久久亚洲午夜电影| 免费成人小视频| 激情欧美丁香| 久久人人爽国产| 欧美va天堂| 亚洲丰满在线| 欧美电影打屁股sp| 亚洲激情成人网| 99国产一区| 欧美日韩在线观看视频| 亚洲三级毛片| 一区二区三区四区蜜桃| 欧美少妇一区| 亚洲一级片在线看| 欧美永久精品| 激情文学综合丁香| 欧美18av| 日韩一二三区视频| 羞羞视频在线观看欧美| 国产在线拍偷自揄拍精品| 久久国产黑丝| 亚洲高清免费| 亚洲一区综合| 国产一区二区三区网站| 久久久综合视频| 亚洲日本成人女熟在线观看| 亚洲一区二区免费视频| 国产欧美日韩伦理| 久热这里只精品99re8久| 亚洲人成久久| 性欧美xxxx视频在线观看| 国产无一区二区| 久久亚洲私人国产精品va| 亚洲精品激情| 久久久高清一区二区三区| 伊人久久亚洲美女图片| 欧美激情一二三区| 亚洲女同性videos| 亚洲国产高清视频| 亚洲欧美日本视频在线观看| 狠色狠色综合久久| 欧美日韩精品综合在线| 欧美影院在线播放| 亚洲欧洲精品一区二区| 久久精品99久久香蕉国产色戒| 亚洲高清资源| 国产精品久久久久久久久搜平片| 久久久91精品| 欧美成人午夜剧场免费观看| 中文在线不卡| 国产综合欧美| 欧美看片网站| 欧美自拍偷拍午夜视频| 亚洲精品一区二区三区婷婷月| 午夜影视日本亚洲欧洲精品| 亚洲黄色高清| 国产欧美日韩中文字幕在线| 欧美日韩国产一区二区三区| 久久精品成人一区二区三区蜜臀| 亚洲日本精品国产第一区| 久久久999国产| 亚洲一级二级| 99re6热在线精品视频播放速度| 国产欧美一区二区三区在线老狼| 欧美日韩成人网| 玖玖玖国产精品| 午夜精品久久久久久久99热浪潮 | 亚洲三级视频在线观看| 国产精品日韩欧美| 欧美精品久久一区| 免费在线欧美黄色| 久久久在线视频| 欧美一区二区三区在线观看| 夜夜嗨av一区二区三区网站四季av | 亚洲人成77777在线观看网| 国产伦精品一区二区三区照片91 | 99国产精品99久久久久久| 韩国精品在线观看| 国产精品亚洲片夜色在线| 欧美视频成人| 欧美日韩一区二区三区免费| 欧美日本高清一区| 欧美激情在线| a4yy欧美一区二区三区| 欧美理论大片| 欧美在线播放视频| 亚洲影院色无极综合| 一区二区冒白浆视频| 日韩亚洲欧美成人| 亚洲第一黄色| 亚洲欧洲视频在线| 亚洲国内自拍| 亚洲欧洲精品一区二区三区不卡| 亚洲第一福利视频| 亚洲大片精品永久免费| 亚洲风情亚aⅴ在线发布| 欧美成人69av| 亚洲激情网址| 日韩一级二级三级| 一区二区欧美日韩| 亚洲影院高清在线| 欧美影片第一页| 久久综合九色| 欧美连裤袜在线视频| 欧美日韩免费一区二区三区| 国产精品ⅴa在线观看h| 国产精品推荐精品| 国产一区二区三区在线观看免费视频| 国内精品久久久久久 | 亚洲日本中文字幕免费在线不卡| 亚洲国产精品一区二区第一页| 亚洲国产日韩在线一区模特| 亚洲欧洲一区二区三区在线观看| 99v久久综合狠狠综合久久| 亚洲视频香蕉人妖| 欧美在线观看视频| 麻豆91精品| 欧美午夜一区二区福利视频| 国产日韩成人精品| 亚洲欧洲日韩女同| 亚洲欧美日韩成人高清在线一区| 久久久免费精品| 亚洲国产精品成人| 亚洲综合视频网| 巨胸喷奶水www久久久免费动漫| 欧美日韩dvd在线观看| 国产乱码精品一区二区三区不卡| 黄色影院成人| 一区二区三区精品久久久| 欧美在线视屏| 91久久精品日日躁夜夜躁国产| 亚洲制服欧美中文字幕中文字幕| 久久久久久久999| 欧美视频在线观看 亚洲欧| 国产一区在线观看视频| 99精品国产99久久久久久福利| 欧美亚洲一级片| 亚洲激情电影在线| 性色av一区二区三区在线观看| 欧美成人午夜| 黑人巨大精品欧美黑白配亚洲 | 亚洲一区二三| 欧美风情在线观看| 亚洲香蕉在线观看| 能在线观看的日韩av| 国产美女精品| 一区二区欧美国产| 亚洲大胆人体在线| 欧美一区1区三区3区公司| 欧美精品尤物在线| **性色生活片久久毛片| 欧美在线二区| 99国产精品久久久久久久成人热| 麻豆国产va免费精品高清在线| 国产伦精品一区二区三区| 亚洲深夜福利在线| 91久久久在线| 麻豆精品精华液| 国内精品久久久| 久久国产免费| 亚洲欧美精品在线观看| 欧美天天影院| 一本色道久久综合亚洲精品不卡| 欧美国产欧美综合| 久久夜色精品| 黑人一区二区| 久久久欧美精品sm网站| 午夜精品婷婷| 国产麻豆精品theporn| 亚洲视频在线观看视频| 91久久精品www人人做人人爽| 久久综合中文色婷婷| 在线精品国产欧美| 免费亚洲一区二区| 久久夜色撩人精品| 亚洲国产成人91精品| 欧美91视频| 暖暖成人免费视频| 亚洲精品麻豆| 亚洲人成毛片在线播放| 欧美日韩国产综合网| 亚洲男女自偷自拍| 亚洲欧美视频在线观看视频| 国产农村妇女精品一区二区| 久久精品成人|