1
、引入:
import
android.provider.Settings;
import
android.content.ContentResolver;
ps:在Setting.System中有如下標誌
WIFI_USE_STATIC_IP
WIFI_STATIC_IP
WIFI_STATIC_NETMASK
WIFI_STATIC_GATEWAY
WIFI_STATIC_DNS1 and WIFI_STATIC_DNS2
2
、在AndroidManifest中加入<uses-permission android:name=
"android.permission.WRITE_SETTINGS"
/>
3
、在Activity中能夠這樣用:
final
ContentResolver mContentResolver = getContentResolver();
Settings.System.putInt( mContentResolver, Settings.System.WIFI_USE_STATIC_IP,
1
);
Settings.System.putString( mContentResolver, Settings.System.WIFI_STATIC_IP,
"你的ip地址"
);
在android程序中怎麼執行ifconfig命令來修改android 的ip地址,