android中与系统相关的工具方法

1.获取系统的skd版本号:
Build.VERSION.SDK

2.获取壁纸,返回值是Drawable :

Drawable drawable = getWallpaper();  

3.获取手机的ip:

    public String getLocalIpAddress() {  
        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()) {  
                        return inetAddress.getHostAddress().toString();  
                    }  
                }  
            }  
        } catch (SocketException ex) {  
            Log.e(LOG_TAG, ex.toString());  
        }  
        return null;  
    }  

设置全屏

getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

设置无标题

requestWindowFeature(Window.FEATURE_NO_TITLE);

设置声音模式

setVolumeControlStream(AudioManager.STREAM_MUSIC);

 



   

你可能感兴趣的:(android中与系统相关的工具方法)