当前位置: 首页>>代码示例>>Java>>正文


Java Formatter.formatIpAddress方法代码示例

本文整理汇总了Java中android.text.format.Formatter.formatIpAddress方法的典型用法代码示例。如果您正苦于以下问题:Java Formatter.formatIpAddress方法的具体用法?Java Formatter.formatIpAddress怎么用?Java Formatter.formatIpAddress使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.text.format.Formatter的用法示例。


在下文中一共展示了Formatter.formatIpAddress方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreate

import android.text.format.Formatter; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    //try to set this WiFi IP (in case there is no [valid] value set yet)
    WifiManager wm = (WifiManager) getApplicationContext().getSystemService(WIFI_SERVICE);
    String wifiIP = Formatter.formatIpAddress(wm.getConnectionInfo().getIpAddress());
    SharedPreferences sPrefs = getSharedPreferences(AppAnalyzer.PREFNAME, MODE_WORLD_READABLE);
    String target_ip = sPrefs.getString(BadIntentConstants.TARGET_IP, " ");
    if (target_ip.equals(" ") || target_ip.equals("0.0.0.0")) {
        sPrefs.edit()
                .putString(BadIntentConstants.TARGET_IP, wifiIP)
                .apply();
    }
    addPreferencesFromResource(R.xml.bad_intent_preferences);

}
 
开发者ID:mateuszk87,项目名称:BadIntent,代码行数:18,代码来源:BadIntentPreferencesActivity.java

示例2: getWifiAddress

import android.text.format.Formatter; //导入方法依赖的package包/类
public static String getWifiAddress(Context context) {
    WifiManager wifiMgr = (WifiManager) context.getApplicationContext().getSystemService(WIFI_SERVICE);
    if(wifiMgr == null){
        return null;
    }
    WifiInfo wifiInfo = wifiMgr.getConnectionInfo();
    int ip = wifiInfo.getIpAddress();
    return Formatter.formatIpAddress(ip);
}
 
开发者ID:hyb1996,项目名称:Auto.js,代码行数:10,代码来源:WifiTool.java

示例3: show_network_info

import android.text.format.Formatter; //导入方法依赖的package包/类
private void show_network_info() {
    WifiManager wm = (WifiManager) getApplicationContext().getSystemService(WIFI_SERVICE);
    String ip = Formatter.formatIpAddress(wm.getConnectionInfo().getIpAddress());
    String mac = wm.getConnectionInfo().getMacAddress();

    StringBuilder sb = new StringBuilder();
    sb.append("WiFi IP address: ");
    sb.append(ip);
    sb.append("\nWiFi MAC address: ");
    sb.append(mac);
    final AlertDialog dialog = new AlertDialog.Builder(this)
            .setTitle(R.string.networkinfo)
            .setMessage(sb.toString())
            .setPositiveButton(R.string.dismiss, null)
            .create();
    dialog.show();
}
 
开发者ID:c3cashdesk,项目名称:postixdroid,代码行数:18,代码来源:MainActivity.java

示例4: startServer

import android.text.format.Formatter; //导入方法依赖的package包/类
protected void startServer() {
        WifiManager wifiMgr = (WifiManager) getApplicationContext()
                .getSystemService(Service.WIFI_SERVICE);
        if (wifiMgr.isWifiEnabled()) {
            // Deprecated. Does not support ipv6. *shrug* :)
            String ipAddress = Formatter.formatIpAddress(wifiMgr.getConnectionInfo()
                    .getIpAddress());

            URI baseUri = UriBuilder.fromUri("http://" + ipAddress)
                    .port(49152)
                    .build();
            ResourceConfig config = new ResourceConfig(SseFeature.class)
                    .register(JacksonFeature.class);
            config.registerInstances(new SecureFilter(this));
            config.registerInstances(new DeskDroidResource(this));
//            server = JettyHttpContainerFactory.createServer(baseUri, config);
            server = GrizzlyHttpServerFactory.createHttpServer(baseUri, config);
        }
    }
 
开发者ID:PacktPublishing,项目名称:Java-9-Programming-Blueprints,代码行数:20,代码来源:DeskDroidService.java

示例5: getIpAddress

import android.text.format.Formatter; //导入方法依赖的package包/类
private String getIpAddress (){

		WifiManager wm = (WifiManager) getApplicationContext().getSystemService(WIFI_SERVICE);
		@SuppressWarnings("deprecation")
		String ip = Formatter.formatIpAddress(wm.getConnectionInfo().getIpAddress());
		Log.d("ANDROID_Launcher","IP:"+ip);
		return ip;
	}
 
开发者ID:cpppwner,项目名称:NoRiskNoFun,代码行数:9,代码来源:AndroidLauncher.java

示例6: getRouterIp

import android.text.format.Formatter; //导入方法依赖的package包/类
public static String getRouterIp(Context context){
    WifiManager wifiService = (WifiManager) context.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
    if(wifiService == null){
        return null;
    }
    DhcpInfo dhcpInfo = wifiService.getDhcpInfo();
    return Formatter.formatIpAddress(dhcpInfo.gateway);
}
 
开发者ID:hyb1996,项目名称:Auto.js,代码行数:9,代码来源:WifiTool.java

示例7: getGatewayIP

import android.text.format.Formatter; //导入方法依赖的package包/类
public static String getGatewayIP(Context context) {
    try {
        return Formatter.formatIpAddress(((WifiManager) context.getSystemService(NETWORK_NAME_WIFI)).getDhcpInfo().gateway);
    } catch (Throwable e) {
        LogTool.e(TAG, "", e);
        return "";
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:9,代码来源:NetworkUtils.java

示例8: getNetPartOfIpAddress

import android.text.format.Formatter; //导入方法依赖的package包/类
public static String getNetPartOfIpAddress(Context context) {
    WifiManager wm = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
    wm.getConnectionInfo().getNetworkId();
    String ip = Formatter.formatIpAddress(wm.getConnectionInfo().getIpAddress());
    ip = ip.substring(0, ip.lastIndexOf('.')+1);
    return ip;
    // TODO: get subnetmask and build net address
}
 
开发者ID:Hatzen,项目名称:PrismatikRemote,代码行数:9,代码来源:NetworkHelper.java

示例9: getIPV4Address

import android.text.format.Formatter; //导入方法依赖的package包/类
/**
 * Get IP address from first non-localhost interface
 * @param ctx is android context
 * @return  address or empty string
 */
public static String getIPV4Address(Context ctx) {
    if(ctx == null){
        return "127.0.0.1";
    }
    WifiManager wm = (WifiManager) ctx.getSystemService(Context.WIFI_SERVICE);
    String ip = Formatter.formatIpAddress(wm.getConnectionInfo().getIpAddress());
    return ip;
}
 
开发者ID:dmtan90,项目名称:Sense-Hub-Android-Things,代码行数:14,代码来源:NetworkUtils.java

示例10: getApIPV4Address

import android.text.format.Formatter; //导入方法依赖的package包/类
public static String getApIPV4Address(Context ctx){
    if(ctx == null){
        return "127.0.0.0";
    }
    WifiManager wm = (WifiManager) ctx.getSystemService(Context.WIFI_SERVICE);
    String ip = Formatter.formatIpAddress(wm.getConnectionInfo().getIpAddress());
    String apIP = ip.substring(0, ip.lastIndexOf(".") + 1) + "0";
    Log.d(TAG, "AP: " + apIP);
    return apIP;
}
 
开发者ID:dmtan90,项目名称:Sense-Hub-Android-Things,代码行数:11,代码来源:NetworkUtils.java

示例11: getGatewayIpAddress

import android.text.format.Formatter; //导入方法依赖的package包/类
public static void getGatewayIpAddress(Context c) {
    // get wifi ip

    final WifiManager manager = (WifiManager) c.getSystemService(Context.WIFI_SERVICE);
    final DhcpInfo dhcp = manager.getDhcpInfo();
    final String address = Formatter.formatIpAddress(dhcp.gateway);

    StringBuilder IFCONFIG = new StringBuilder();
    try {
        for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements(); ) {
            NetworkInterface intf = en.nextElement();
            for (Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements(); ) {
                InetAddress inetAddress = enumIpAddr.nextElement();
                if (!inetAddress.isLoopbackAddress() && !inetAddress.isLinkLocalAddress()
                        && inetAddress.isSiteLocalAddress()) {
                    IFCONFIG.append(inetAddress.getHostAddress().toString() + "\n");
                }

            }
        }
    } catch (SocketException ex) {
        Log.e("LOG_TAG", ex.toString());
    }
    MLog.d(TAG, "ifconfig " + IFCONFIG.toString());

    MLog.d(TAG, "hotspot address is " + address);

}
 
开发者ID:victordiaz,项目名称:phonk,代码行数:29,代码来源:NetworkUtils.java

示例12: getWifiAddress

import android.text.format.Formatter; //导入方法依赖的package包/类
public static String getWifiAddress(Context context) {
    WifiManager wifiMgr = (WifiManager) context.getApplicationContext().getSystemService(WIFI_SERVICE);
    WifiInfo wifiInfo = wifiMgr.getConnectionInfo();
    int ip = wifiInfo.getIpAddress();
    return Formatter.formatIpAddress(ip);
}
 
开发者ID:feifadaima,项目名称:https-github.com-hyb1996-NoRootScriptDroid,代码行数:7,代码来源:WifiTool.java

示例13: getIpAddress

import android.text.format.Formatter; //导入方法依赖的package包/类
public static String getIpAddress(Context context) {
    WifiManager wm = (WifiManager) context.getSystemService(WIFI_SERVICE);
    return Formatter.formatIpAddress(wm.getConnectionInfo().getIpAddress());
}
 
开发者ID:aschober,项目名称:vinyl-cast,代码行数:5,代码来源:Helpers.java

示例14: getIpAddress

import android.text.format.Formatter; //导入方法依赖的package包/类
public static String getIpAddress(Context context) {
  WifiManager wm = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
  return Formatter.formatIpAddress(wm.getConnectionInfo().getIpAddress());
}
 
开发者ID:zugaldia,项目名称:android-robocar,代码行数:5,代码来源:LocalWebServer.java

示例15: GetIp

import android.text.format.Formatter; //导入方法依赖的package包/类
public String GetIp() {
    return Formatter.formatIpAddress(_wifiManager.getConnectionInfo().getIpAddress());
}
 
开发者ID:GuepardoApps,项目名称:LucaHome-AndroidApplication,代码行数:4,代码来源:UserInformationController.java


注:本文中的android.text.format.Formatter.formatIpAddress方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。