解决方案 »

  1.   


    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地址");
      

  2.   

    android里面wifi的静态ip和以太网ip应该是不一样的吧?
      

  3.   

    首先要ROOT,然后执行shell语句,好像你写的执行shell语句方法有误,, 
      

  4.   

    我是新手,我的设备已经root了,不知道该怎么搞,正确的shell语句该怎么写啊?这个问题已经纠结好久了,能指点一下吗?
      

  5.   

    Stringcom={shell语句};
     try{
     Process suProcess = Runtime.getRuntime().exec("su");
    DataOutputStream os = new DataOutputStream(suProcess.getOutputStream());
    // Execute commands that require root access
    os.writeBytes(com+ "\n");
    os.flush();
    os.writeBytes("exit\n");
    os.flush();
     }catch (IOException e) {
                e.printStackTrace();
            } catch (Exception e) {
                e.printStackTrace();
            } 
    }
      

  6.   

    应该是权限问题吧,把程序倒到/system/app下面试一试
      

  7.   

    Runtime.getRuntime().exec("adb shell am ifconfig eth0 192.168.1.110 netmask 255.255.255.0 up");