无线设置对话框 [英] Wireless settings dialog

查看:217
本文介绍了无线设置对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我检查使用下面的code网络连接:

 公共静态布尔haveInternet(上下文CTX)
{
    的NetworkInfo信息=(的NetworkInfo)((ConnectivityManager)ctx.getSystemService(Context.CONNECTIVITY_SERVICE))getActiveNetworkInfo()。

   如果(资讯== NULL ||!info.isConnected()){
          返回false; // 无连接
   }

  返回true; //如果有连接真实
}
 

现在,在无连接,我推出无线设置使用下面的code对话框:

  context.startActivity(新意图(Settings.ACTION_WIRELESS_SETTINGS));
 

在这里,用户能够开/关无线,现在我怎么来知道用户是否已取得上的Wi-Fi或不?即什么结果由成功的无线连接上的上述意图返回。我如何检查呢?

我想我需要调用startActivityForResult方法,但不知道该怎么做呢?

更新:

我想要做同样的方式 http://groups.google.is /组/ Android的开发者/味精/ 6874a5e4675dffdb

解决方案
  

现在我怎么来知道用户是否已取得上的Wi-Fi或不?即什么结果由成功的无线连接上的上述意图返回。我如何检查呢?

没有结果。您可以通过调用你上面显示的code检,或通过监测相关广播意图(见 ConnectivityManager CONNECTIVITY_ACTION WifiManager WIFI_STATE_CHANGED_ACTION NETWORK_STATE_CHANGED_ACTION

  

我想我需要调用startActivityForResult方法,但不知道该怎么做呢?

这项活动不支持 startActivityForResult()

i am checking networking connection using the below code:

public static boolean haveInternet(Context ctx) 
{
    NetworkInfo info = (NetworkInfo) ((ConnectivityManager) ctx.getSystemService(Context.CONNECTIVITY_SERVICE)).getActiveNetworkInfo();

   if (info == null || !info.isConnected()) {
          return false;  // no connection
   }

  return true;   // true if having connection
}       

Now, on "no connection" , i am launching "Wireless settings" dialog using the below code:

    context.startActivity(new Intent(Settings.ACTION_WIRELESS_SETTINGS));

Here, user is being able to "on/off" the wireless, now how do i come to know whether the user has made "on" the wi-fi or not? i.e. what result is returned by the above intent on the successful wireless connection. how do i check it ?

I think i need to call startActivityForResult method, but dont know how do i do it ?

Update:

I want to do same way as http://groups.google.is/group/android-developers/msg/6874a5e4675dffdb

解决方案

now how do i come to know whether the user has made "on" the wi-fi or not? i.e. what result is returned by the above intent on the successful wireless connection. how do i check it ?

There is no result. You check it by calling the code you have shown above, or by monitoring relevant broadcast Intents (see ConnectivityManager and its CONNECTIVITY_ACTION or WifiManager and its WIFI_STATE_CHANGED_ACTION or NETWORK_STATE_CHANGED_ACTION).

I think i need to call startActivityForResult method, but dont know how do i do it ?

That activity does not support startActivityForResult().

这篇关于无线设置对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆