Back to project page FileShare.
The source code is released under:
MIT License
If you think the Android project FileShare listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.csyangchsh.fileshare; //from w w w. ja va2s . c o m import android.app.Application; import android.content.Context; import android.net.ConnectivityManager; import android.net.NetworkInfo; import android.net.wifi.WifiManager; import android.text.format.Formatter; import com.csyangchsh.fileshare.util.TempFileFactory; import java.net.InetAddress; import java.net.NetworkInterface; import java.util.Enumeration; /** * @author csyangchsh * 2014-08-28 */ public class FSApplication extends Application{ public static TempFileFactory fileFactory; private static ConnectivityManager connManager; private static WifiManager wifiManager; @Override public void onCreate() { super.onCreate(); fileFactory = new TempFileFactory(); connManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); wifiManager = (WifiManager) getSystemService(WIFI_SERVICE); } @Override public void onTerminate() { super.onTerminate(); fileFactory.destroy(); } public static boolean isWifi() { NetworkInfo wifi = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI); return wifi.isConnected(); } public static String getIPAddress() { int ipAddress = wifiManager.getConnectionInfo().getIpAddress(); String ip = Formatter.formatIpAddress(ipAddress); return ip; } }