1. 程式人生 > >應用程式中的一些配置(許可權)

應用程式中的一些配置(許可權)

給應用配置許可權:
<uses-permission android:name="android.permission.CALL_PHONE" />//打電話的許可權

<uses-permission android:name="android.permission.INTERNET" />//訪問網路的許可權

<user-permission  android:name="android.permission.SEND_SMS"//傳送簡訊的許可權

android:screenOrientation="landscape"//橫屏顯示
android:screenOrientation=“portrait”//豎屏顯示
android:configChanges="keyboardHidden|orientation|screenSize"//橫豎屏切換時不讓activity銷燬。此時會呼叫onConfigChanges()

安卓中生成庫檔案:
比如像c#中的dll檔案,生成庫檔案步驟:工程-右鍵選屬性-android-勾選 is library
其他工程匯入庫檔案步驟:工程-右鍵選屬性-android-add-選擇要匯入的庫
生成Jar包的方法:檔案-匯出-Java

讓程式啟動時建立自己定義的application類物件:
public myApplication extends  application(){...}
然後在<application>節點中配置:android:name="包名.myApplication"

要開啟其他應用程式的activity,其他應用程式的activity要設定屬性:android:exported=true,預設是false

把activity變為透明:android:theme="@android:style/theme.translucent"
關閉activity:finish()

getWindow().getWindowManager().getDefaultDispaly().getHeight()
ANR(application no responding):主介面在無法響應輸入事件(超過6s的行為)

長度單位:
px:表示螢幕實際的畫素。
dp:是螢幕的物理尺寸,適用於控制元件
sp:與刻度無關的畫素,適用於字型

啟動系統中的activity元件:

    撥打電話:intent.setAction(intent.ACTION_CALL);//intent.ACTION_DIAG//是開啟系統的撥號介面

    傳送簡訊:

          Uri _url=new  Uri.parse("smsto:"+"10086");//要傳送的手機號

          intent.setData(_url);

         intent.setAction(intent.ACTION_SENDTO);

         intent.putExtra("string","內容");//傳送的簡訊內容

    開啟相機:intent.setAction(MediaStore.ACTION_IMAGE_CAPTURE);