爪哇夜未眠:杰哥走向架构之路
itanger
全部博文(215)
DreamWeaver(2)
Div+Css(1)
系统(4)
BIOS(1)
websphere(2)
工具类(1)
android(16)
Lucene(1)
Log4j(1)
Jboss(1)
Java架构(3)
J2ee(2)
SSH(2)
WebService(2)
WML-无线标记语言(2)
WebLogic(3)
iBatis(1)
EJB(3)
Spring(3)
JAVA基础(17)
Eclipse(3)
OSCache(1)
Tomcat(6)
服务器(0)
数据库(3)
Servlet(1)
算法(3)
JBuilder(1)
Hibenate(9)
JSF(7)
Struts(14)
2012年(1)
2011年(24)
2009年(16)
2008年(91)
2007年(83)
asacml
追梦小花
cynthia
浪花小雨
dr282235
alanhe21
pjchen
davelv
limengji
分类: Java
2011-01-12 14:31:07
1.管理wifi :
private WifiManager wifiManager = null;
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); startButton = (Button)findViewById(R.id.startWifi); stopButton = (Button)findViewById(R.id.stopWifi); checkButton = (Button)findViewById(R.id.checkWifi); startButton.setOnClickListener(new StartWifiListener()); stopButton.setOnClickListener(new StopWifiListener()); checkButton.setOnClickListener(new CheckWifiListener()); } class StartWifiListener implements OnClickListener{
@Override public void onClick(View v) { wifiManager = (WifiManager)WifiActivity.this.getSystemService(Context.WIFI_SERVICE); wifiManager.setWifiEnabled(true); System.out.println("wifi state --->" + wifiManager.getWifiState()); Toast.makeText(WifiActivity.this, "当前Wifi网卡状态为" + wifiManager.getWifiState(), Toast.LENGTH_SHORT).show(); } } class StopWifiListener implements OnClickListener{
@Override public void onClick(View arg0) { // TODO Auto-generated method stub wifiManager = (WifiManager)WifiActivity.this.getSystemService(Context.WIFI_SERVICE); wifiManager.setWifiEnabled(false); System.out.println("wifi state --->" + wifiManager.getWifiState()); Toast.makeText(WifiActivity.this, "当前Wifi网卡状态为" + wifiManager.getWifiState(), Toast.LENGTH_SHORT).show(); } } class CheckWifiListener implements OnClickListener{
@Override public void onClick(View v) { wifiManager = (WifiManager)WifiActivity.this.getSystemService(Context.WIFI_SERVICE); System.out.println("wifi state --->" + wifiManager.getWifiState()); Toast.makeText(WifiActivity.this, "当前Wifi网卡状态为" + wifiManager.getWifiState(), Toast.LENGTH_SHORT).show(); } }
上一篇:霓虹灯的实现
下一篇:nofication范例
登录 注册