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地址,