一、程式常用許可權
android.permission.INTERNET
允許程式連網,非常常用(Allows applications to open network sockets)
android.permission.ACCESS_COARSE_LOCATION
允許一個程式訪問CellID或WiFi熱點來擷取粗略的位置(Allows an application to access coarse (e.g., Cell-ID, WiFi) location)
android.permission.ACCESS_FINE_LOCATION
允許一個程式訪問精良位置(如GPS) (Allows an application to access fine (e.g., GPS) location)
android.permission.ACCESS_NETWORK_STATE
允許程式訪問有關GSM網路資訊(Allows applications to access information about networks)
android.permission.ACCESS_WIFI_STATE
允許程式訪問Wi-Fi網路狀態資訊(Allows applications to access information about Wi-Fi networks)
android.permission.CHANGE_WIFI_STATE
允許程式改變Wi-Fi串連狀態(Allows applications to change Wi-Fi connectivity state)
android.permission.CHANGE_NETWORK_STATE
允許程式改變網路連接狀態(Allows applications to change network connectivity state)
android.permission.CAMERA
請求訪問使用照相裝置(Required to be able to access the camera device. )
android.permission.VIBRATE
允許訪問震動裝置(Allows access to the vibrator)
二、檢查SD卡是否存在,並取出絕對路徑:
String rootPath = null;<br />if(Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED))<br />{<br />rootPath = Environment.getExternalStorageDirectory().getAbsolutePath();<br />}<br />
三、建立檔案夾
/*<br /> * @see 建立一個絕對路徑目錄<br /> * @param 絕對路徑<br /> * @return 是否建立成功<br /> */<br />public boolean createFolder(String fullpath)<br />{<br />try {<br />File path = new File(fullpath);<br />if(!path.exists())<br />{<br />path.mkdir();<br />}<br />return true;<br />} catch (Exception e) {<br />// TODO: handle exception<br />Log.w("apkdev", "FileManager.createFolder: "+"Please Check path " + fullpath);<br />return false;<br />}<br />}
四、這裡講下如何禁止橫屏和豎屏切換
在某些遊戲中我們可能需要禁止橫屏和豎屏切換,只要在
AndroidManifest.xml 裡面加入這一行 android :screenOrientation="landscape "(landscape 是橫向,portrait 是縱向)。
在android中每次螢幕的切換動會重啟Activity,所以應該在Activity銷毀前儲存當前活動的狀態,在Activity再次Create的時候載入配置。在activity加上android:configChanges="keyboardHidden|orientation"屬性,就不會重啟activity.而是去調用onConfigurationChanged(Configuration newConfig). 這樣就可以在這個方法裡調整顯示方式.
不斷更新中...