How to Configure Static Ethernet Parameters Using API
The system provides the AIDL interface to set the preferred network type, When connect the service, the package name is com.wizarpos.wizarviewagentassistant, and the class name is com.wizarpos.wizarviewagentassistant.Eth0MgrService. When the application uses the interface, it must import wizarviewagentassistant and add permissions to the Android manifest file.
Permission
The application declares the following permissions in the manifest:
android.permission.CONNECTIVITY_INTERNAL
API Overview
enableStaticIp
void enableStaticIp(boolean isStaticIp);
Enable static IP, true for static ip, else for dhcp.
Parameters | |
---|---|
isStaticIp | boolean: true for static ip, else for dhcp. |
isStaticIp
boolean isStaticIp();
true for static ip, else for dhcp.
Returns | |
---|---|
boolean | true is static IP. |
setStaticIp
boolean setStaticIp(IpBean ipBean);
Set static IP.
Parameters | |
---|---|
ipBean | IpBean |
Returns | |
---|---|
boolean | true is success, false is failure. |
getStaticIp
IpBean getStaticIp();
Get static IP parameters.
Returns | |
---|---|
IpBean | IpBean. |
public class IpBean implements Parcelable {
private String ipAddress;
private String prefixLength;
private String gateway;
private String dnsServer;
public IpBean(){}
protected IpBean(Parcel in) {
ipAddress = in.readString();
prefixLength = in.readString();
gateway = in.readString();
dnsServer = in.readString();
}
public static final Creator<IpBean> CREATOR = new Creator<IpBean>() {
@Override
public IpBean createFromParcel(Parcel in) {
return new IpBean(in);
}
@Override
public IpBean[] newArray(int size) {
return new IpBean[size];
}
};
public String getIpAddress() {
return ipAddress;
}
public void setIpAddress(String ipAddress) {
this.ipAddress = ipAddress;
}
public String getPrefixLength() {
return prefixLength;
}
public void setPrefixLength(String prefixLength) {
this.prefixLength = prefixLength;
}
public String getGateway() {
return gateway;
}
public void setGateway(String gateway) {
this.gateway = gateway;
}
public String getDnsServer() {
return dnsServer;
}
public void setDnsServer(String dnsServer) {
this.dnsServer = dnsServer;
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(this.ipAddress);
dest.writeString(this.prefixLength);
dest.writeString(this.gateway);
dest.writeString(this.dnsServer);
}
@Override
public String toString() {
return "IpBean{" +
"ipAddress='" + ipAddress + '\'' +
", prefixLength='" + prefixLength + '\'' +
", gateway='" + gateway + '\'' +
", dnsServer='" + dnsServer + '\'' +
'}';
}
}
Download
Demo
Please download the demo