當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。