Android的:如何设置静态IP为新的无线网络配置无线网络、静态、如何设置、Android

由网友(总是不停敷衍不停抱歉)分享简介:再次陷入同样的​​问题。Again stuck on the same problem.我已经找到了解决,我们可以设置静态的系统设置是这样的:I have found around that we can set static system settings like this:System.putString...

再次陷入同样的​​问题。

Again stuck on the same problem.

我已经找到了解决,我们可以设置静态的系统设置是这样的:

I have found around that we can set static system settings like this:

System.putString(getContentResolver(), android.provider.Settings.System.WIFI_USE_STATIC_IP, "1"); // to define it use static ip's
System.putString(getContentResolver(), android.provider.Settings.System.WIFI_STATIC_IP,"192.168.1.15");
System.putString(getContentResolver(), android.provider.Settings.System.WIFI_STATIC_NETMASK,"255.255.255.0");
System.putString(getContentResolver(), android.provider.Settings.System.WIFI_STATIC_DNS1,"192.168.1.1");
System.putString(getContentResolver(), android.provider.Settings.System.WIFI_STATIC_GATEWAY,"192.168.1.1");

但否成功!

我不明白,当设置这些设置吗?

I don't understand that when to set these settings?

如果我的无线网络配置之前创建或保存无线配置之后或之前将其激活或之后做呢?

Should I do it before the wifi configuration creation or after saving the wifi configuration or even before activating it or after it?

不过,我已经尝试了所有可能的情况下,从我的身边,当我检查Android的无线网络设置,我看它仍然在DHCP。

However, I have tried the all possible cases from my side and when I check Android WiFi settings, I see it's still on DHCP.

一个previous问题,即How以configue静态IP,子网掩码,网关编程在Android 3.x或4.x的已经完全毁了我的Andr​​oid设备,现在,它不能切换 它的无线网络了。

A previous question i.e. How to configue static IP, netmask ,gateway programmatically on Android 3.x or 4.x has completely ruined my android device and now it can't switch ON its WiFi anymore.

我也试过在我的HTC手机,并没有成功,它总是在DHCP模式下!

I also tried static IP on my HTC phone and no success, its always in DHCP mode!

我是否需要调用重新连接的命令?如果是的话,那么以何种方式?

Do I need to call a "reconnect" command? If yes, then in which way?

推荐答案

一年多后,我放弃了设置静态IP(或DHCP,DNS,...)。只要它是不可能的,或者更好的,它是不允许的(从任意应用程序)。

After more than a year, I give up with setting a static IP (or DHCP, DNS, ...). Simply it's not possible, or, better, it's not allowed (from an arbitrary application).

有人说:

你可以使用NDK - 这给你的Andr​​oid下Linux的低级别的访问权限警告:不要期望这是记录或支持,他们甚至可能会禁止你从Android Market(我知道我会。 )的

对于那些谁希望有一些expriences与NDK,这里是一个链接:

For those who want to have some expriences with NDK, here is the a link:

http://developer.android.com/tool​​s/sdk/ndk/ index.html的

祝你好运,并给予一定的反馈,如果你发现一些有趣的事情!

Good luck, and give some feedback if you find something interesting!

阅读全文

相关推荐

最新文章