Android中MimeType查询

根据扩展名取mime type

MimeTypeMap.getSingleton().getExtensionFromMimeType(“png”);//返回”image/png”

根据mime type 取扩展名

MimeTypeMap.getSingleton().getMimeTypeFromExtension(“image/png”);//返回png

Android限制屏幕旋转

在AndroidManifest.xml中的activity上加上android:screenOrientation属性。

如:

android:screenOrientation=”portrait” 只允许竖屏

android:screenOrientation=”landscape” 只允许横屏

Android禁止屏幕休眠

<uses-permission android:name="android.permission.WAKE_LOCK" />
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //要写在setContentView之前?
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON,  WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    setContentView(R.layout.main);
}