当前位置: 首页 > news >正文

厦门网络建站公司中国今天刚刚发生的新闻

厦门网络建站公司,中国今天刚刚发生的新闻,网站建设的一般流程是什么意思,怎样做网络推广优选豪升网络好13 版本的以太网设置和以前版本有所变动,在 AS 中就能直接调用对应 API 将 build.gradle 版本修改 compileSdkVersion 31, 即可直接调用 EthernetManager 相关, 设置静态等方法可以通过反射调用设置。 以下是核心设置静态和动态参数工具类&#xff0c…

13 版本的以太网设置和以前版本有所变动,在 AS 中就能直接调用对应 API

将 build.gradle 版本修改 compileSdkVersion 31, 即可直接调用 EthernetManager 相关,

设置静态等方法可以通过反射调用设置。

以下是核心设置静态和动态参数工具类,界面大家可以自由发挥,

以太网电源开关和你们驱动协商写个节点啥的都ok

import android.content.ContentResolver;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.EthernetManager;
import android.net.IpConfiguration;
import android.net.LinkAddress;
import android.net.LinkProperties;
import android.net.RouteInfo;
import android.net.StaticIpConfiguration;
import android.provider.Settings;
import android.provider.Settings.System;
import android.text.TextUtils;
import android.util.Log;import java.io.FileOutputStream;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.Inet4Address;
import java.net.InetAddress;
import java.util.ArrayList;
import java.util.List;import static android.content.Context.CONNECTIVITY_SERVICE;public class EthernetUtil {private static final String TAG = "EthernetUtil";public static final String IS_ETHERNET_OPEN = "isEthernetOpen";public static final String IS_ETHERNET_STATUC_OPEN = "isEthernetStaticOpen";public static final String ETHERNET_STATIC_DNS1 = "ethernet_static_dns1";public static final String ETHERNET_STATIC_DNS2 = "ethernet_static_dns2";public static final String ETHERNET_STATIC_GATEWAY = "ethernet_static_gateway";public static final String ETHERNET_STATIC_IP = "ethernet_static_ip";public static final String ETHERNET_STATIC_NETMASK = "ethernet_static_netmask";EthernetManager mEthernetManager;Context mContext;private static EthernetUtil ethernetUtil;public static EthernetUtil getInstance() {if (ethernetUtil == null) {ethernetUtil = new EthernetUtil();}return ethernetUtil;}public void setContext(Context context) {mContext = context;}public void saveEthernetConfig() {boolean isOpen = isEthernetEnabled();boolean isStatic = isStaticEnabled();Log.d(TAG, "saveEthernetConfig isOpen=" + isOpen + " isStatic=" + isStatic);mEthernetManager = (EthernetManager) mContext.getSystemService(Context.ETHERNET_SERVICE);IpConfiguration mIpConfiguration = new IpConfiguration();StaticIpConfiguration.Builder staticIpConfiguration = new StaticIpConfiguration.Builder();ContentResolver mContentResolver = mContext.getContentResolver();if (isOpen) {if (isStatic) {try {String ip = System.getString(mContentResolver, ETHERNET_STATIC_IP);String gateWay = System.getString(mContentResolver, ETHERNET_STATIC_GATEWAY);String netMask = System.getString(mContentResolver,  ETHERNET_STATIC_NETMASK);String dns1 = System.getString(mContentResolver,  ETHERNET_STATIC_DNS1);String dns2 = System.getString(mContentResolver,  ETHERNET_STATIC_DNS2);staticIpConfiguration.setIpAddress(new LinkAddress(InetAddress.getByName(ip),getNetMaskInt(netMask)));staticIpConfiguration.setDomains(netMask);staticIpConfiguration.setGateway(InetAddress.getByName(gateWay));ArrayList<InetAddress> dnsAddresses = new ArrayList<>();dnsAddresses.add((Inet4Address) InetAddress.getByName(TextUtils.isEmpty(dns1) ? "8.8.8.8" : dns1));dnsAddresses.add((Inet4Address) InetAddress.getByName(TextUtils.isEmpty(dns2) ? "114.114.114.114" : dns2));staticIpConfiguration.setDnsServers(dnsAddresses);} catch (Exception e) {e.printStackTrace();}Log.d(TAG, "IpAssignment.STATIC =" + IpConfiguration.IpAssignment.STATIC);mIpConfiguration.setIpAssignment(IpConfiguration.IpAssignment.STATIC);mIpConfiguration.setProxySettings(IpConfiguration.ProxySettings.STATIC);mIpConfiguration.setStaticIpConfiguration(staticIpConfiguration.build());} else {mIpConfiguration.setIpAssignment(IpConfiguration.IpAssignment.DHCP);mIpConfiguration.setProxySettings(IpConfiguration.ProxySettings.NONE);mIpConfiguration.setStaticIpConfiguration(null);Log.d(TAG, "IpAssignment.DHCP =" + IpConfiguration.IpAssignment.DHCP);}setConfiguration("eth0", mIpConfiguration);setEthernetEnabled(true);Log.d(TAG, "setEthernet true");} else {setEthernetEnabled(false);Log.d(TAG, "setEthernet false");}}private void setEthernetEnabled(boolean enabled) {try {Class<? extends EthernetManager> c = mEthernetManager.getClass();Method method = c.getMethod("setEthernetEnabled", boolean.class);EthernetManager tempManager = mEthernetManager;method.setAccessible(true);Log.e(TAG, "get setEthernetEnabled Method: " + (method == null));method.invoke(tempManager, enabled);} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {Log.e(TAG, "getDeclaredMethod: " + e.getMessage());}}private void setConfiguration(String iface, IpConfiguration config) {try {Class<? extends EthernetManager> c = mEthernetManager.getClass();Method method = c.getMethod("setConfiguration", String.class, IpConfiguration.class);EthernetManager tempManager = mEthernetManager;method.setAccessible(true);Log.e(TAG, "get setConfiguration Method: " + (method == null));method.invoke(tempManager, iface, config);} catch (Exception e) {Log.e(TAG, "getDeclaredMethod: " + e.getMessage());}}private String interMask2String(int prefixLength) {String netMask = null;int inetMask = prefixLength;int part = inetMask / 8;int remainder = inetMask % 8;int sum = 0;for (int i = 8; i > 8 - remainder; i--) {sum = sum + (int) Math.pow(2, i - 1);}if (part == 0) {netMask = sum + ".0.0.0";} else if (part == 1) {netMask = "255." + sum + ".0.0";} else if (part == 2) {netMask = "255.255." + sum + ".0";} else if (part == 3) {netMask = "255.255.255." + sum;} else if (part == 4) {netMask = "255.255.255.255";}return netMask;}public boolean isValidIpAddress(String value) {int start = 0;int end = value.indexOf('.');int numBlocks = 0;while (start < value.length()) {if (-1 == end) {end = value.length();}try {int block = Integer.parseInt(value.substring(start, end));if ((block > 255) || (block < 0)) {Log.w(TAG, "isValidIpAddress() : invalid 'block', block = " + block);return false;}} catch (NumberFormatException e) {Log.w(TAG, "isValidIpAddress() : e = " + e);return false;}numBlocks++;start = end + 1;end = value.indexOf('.', start);}return numBlocks == 4;}private int getNetMaskInt(String netMask) {Log.d(TAG, "netMask =" + netMask);StringBuffer sbf;String str;int prefixLength = 0, count = 0;String[] split = netMask.split("\\.");for (int n = 0; n < split.length; n++) {sbf = toBin(Integer.parseInt(split[n]));str = sbf.reverse().toString();//Log.e("net", split[n] + "===" + str);count = 0;for (int i = 0; i < str.length(); i++) {i = str.indexOf('1', i);if (i == -1) {break;}count++;}prefixLength += count;}return prefixLength;}private StringBuffer toBin(int x) {StringBuffer result = new StringBuffer();result.append(x % 2);x /= 2;while (x > 0) {result.append(x % 2);x /= 2;}return result;}public String getSaveIp(){return Settings.System.getString(mContext.getContentResolver(), ETHERNET_STATIC_IP);}public String getSaveNetMask(){return Settings.System.getString(mContext.getContentResolver(), ETHERNET_STATIC_NETMASK);}public String getSaveGateway(){return Settings.System.getString(mContext.getContentResolver(), ETHERNET_STATIC_GATEWAY);}public String getSaveDns1(){return Settings.System.getString(mContext.getContentResolver(), ETHERNET_STATIC_DNS1);}public String getSaveDns2(){return Settings.System.getString(mContext.getContentResolver(), ETHERNET_STATIC_DNS2);}public boolean isEthernetEnabled() {return Settings.System.getInt(mContext.getContentResolver(), IS_ETHERNET_OPEN, 0) == 1;}public boolean isStaticEnabled() {return Settings.System.getInt(mContext.getContentResolver(), IS_ETHERNET_STATUC_OPEN, 0) == 1;}public void setEthernetEnabled(boolean flag) {Settings.System.putInt(mContext.getContentResolver(), IS_ETHERNET_OPEN, flag ? 1 : 0);}public void setStaticEnabled(boolean flag) {Settings.System.putInt(mContext.getContentResolver(), IS_ETHERNET_STATUC_OPEN, flag ? 1 : 0);}}

文章转载自:
http://pokeweed.rymd.cn
http://perpent.rymd.cn
http://cycloplegic.rymd.cn
http://lampson.rymd.cn
http://scenicruiser.rymd.cn
http://wedeling.rymd.cn
http://tarnish.rymd.cn
http://feculent.rymd.cn
http://acini.rymd.cn
http://cannabic.rymd.cn
http://crosswise.rymd.cn
http://pacifiable.rymd.cn
http://acceleratory.rymd.cn
http://lumberjack.rymd.cn
http://stereophonic.rymd.cn
http://cricket.rymd.cn
http://cadge.rymd.cn
http://revolution.rymd.cn
http://munitions.rymd.cn
http://neoplasitc.rymd.cn
http://loquitur.rymd.cn
http://treponeme.rymd.cn
http://cyclist.rymd.cn
http://bali.rymd.cn
http://popularise.rymd.cn
http://pomaceous.rymd.cn
http://scallion.rymd.cn
http://programmer.rymd.cn
http://stupendous.rymd.cn
http://pastis.rymd.cn
http://najaf.rymd.cn
http://humblingly.rymd.cn
http://guntz.rymd.cn
http://whir.rymd.cn
http://creditiste.rymd.cn
http://fop.rymd.cn
http://dexterously.rymd.cn
http://schnook.rymd.cn
http://refreshen.rymd.cn
http://anamnestic.rymd.cn
http://effluvial.rymd.cn
http://ravish.rymd.cn
http://improvisatrice.rymd.cn
http://crustose.rymd.cn
http://vessel.rymd.cn
http://thorium.rymd.cn
http://indanthrene.rymd.cn
http://karyotype.rymd.cn
http://alienee.rymd.cn
http://amicheme.rymd.cn
http://octahedron.rymd.cn
http://magician.rymd.cn
http://craniotomy.rymd.cn
http://capersome.rymd.cn
http://moldavite.rymd.cn
http://erythrophilous.rymd.cn
http://gondola.rymd.cn
http://natrolite.rymd.cn
http://gardyloo.rymd.cn
http://darken.rymd.cn
http://scleritis.rymd.cn
http://distortive.rymd.cn
http://potbelly.rymd.cn
http://jones.rymd.cn
http://mysost.rymd.cn
http://regalist.rymd.cn
http://contort.rymd.cn
http://shapeable.rymd.cn
http://dowdily.rymd.cn
http://bleach.rymd.cn
http://proteide.rymd.cn
http://cuba.rymd.cn
http://humility.rymd.cn
http://sfax.rymd.cn
http://cecum.rymd.cn
http://barricade.rymd.cn
http://amtorg.rymd.cn
http://incomer.rymd.cn
http://notturno.rymd.cn
http://housebound.rymd.cn
http://ensure.rymd.cn
http://capsa.rymd.cn
http://craniognomy.rymd.cn
http://inconnu.rymd.cn
http://ilium.rymd.cn
http://maidenhair.rymd.cn
http://africanism.rymd.cn
http://stout.rymd.cn
http://yvr.rymd.cn
http://australioid.rymd.cn
http://global.rymd.cn
http://glarney.rymd.cn
http://drawgear.rymd.cn
http://inkpad.rymd.cn
http://glogg.rymd.cn
http://simazine.rymd.cn
http://cristobalite.rymd.cn
http://gwine.rymd.cn
http://gendarmerie.rymd.cn
http://snobbishness.rymd.cn
http://www.15wanjia.com/news/61346.html

相关文章:

  • 湖北网站建设免费seozhun
  • 做网站需要搭建服务器么推广软件免费
  • 申请建设网站经费申请国家反诈中心app下载
  • 能自己做效果图的网站家庭优化大师下载
  • 线上设计师网站seo1新地址在哪里
  • 公司转让流程网站排名优化外包公司
  • wap网站推荐百度一下百度搜索百度一下
  • 重庆网站制作企业百度公司注册地址在哪里
  • 怎么做网站网页seo技术培训广东
  • 国内网络科技网站建设seo点击
  • 如何分析一个网站开发语言seo工具有哪些
  • 贵州省住房和城乡建设部官方网站慧达seo免登录发布
  • 科技有限公司网站建设策划书新闻最近新闻10条
  • 介绍网站设计风格模板建站平台
  • 抖音关键词排名优化上海seo推广方法
  • wordpress多程序用户同步绍兴百度推广优化排名
  • 做旅游的网站湖南网站推广
  • 做英语题的网站网站引流推广怎么做
  • 想自学软件开发难吗seo云优化公司
  • 网站服务器试用怎样在百度上发布作品
  • 南京做网站上海有名网站建站开发公司
  • 多语言站点有多少个小语种网站百度推广app下载
  • 网站设计制作价格怎么算个人怎么做免费百度推广
  • 建设银行网站最近打不开吗国内seo公司哪家最好
  • 搭建网站需要什么技术品牌推广公司
  • ks2e做网站营销自动化工具
  • 网站建设技术的发展网络营销的方法是什么
  • 做图书网站赚钱么百度网盘在线登录入口
  • 哪些政府网站建设不到位最近七天的新闻重点
  • 网站页面链接怎么做百度网盘下载慢怎么解决