Android³£¼ûÎÊÌâ½â´ð

µ¼Óï Á˽âAndroidϵͳ¼Ü¹¹ Ó¦Óòã: Java Ó¦Óÿª·¢¹¤³Ìʦ¿ª·¢µÄËùÓÐÓ¦ÓóÌÐò±ÈÈçµØͼ,ä¯ÀÀÆ÷,QQµÈÊôÓڸòã, ÊÖ»úÖеĶÌÐÅ,²¦ºÅ,ä¯ÀÀÆ÷µÈÕâЩӦÓóÌÐò¶¼ÊÇ¿ÉÒÔ±»¿ª·¢ÈËÔ±¿ª·¢µÄÆäËûÓ¦ÓóÌÐòËùÌæ»»£¬ Õâµã²»Í¬ÓÚÆäËû
  1. Á˽âAndroidϵͳ¼Ü¹¹ Ó¦Óòã: Java Ó¦Óÿª·¢¹¤³Ìʦ¿ª·¢µÄËùÓÐÓ¦ÓóÌÐò±ÈÈçµØͼ,ä¯ÀÀÆ÷,QQµÈÊôÓڸòã, ÊÖ»úÖеĶÌÐÅ,²¦ºÅ,ä¯ÀÀÆ÷µÈÕâЩӦÓóÌÐò¶¼ÊÇ¿ÉÒÔ±»¿ª·¢ÈËÔ±¿ª·¢µÄÆäËûÓ¦ÓóÌÐòËùÌæ»»£¬ Õâµã²»Í¬ÓÚÆäËûÊÖ»ú²Ù×÷ϵͳ¹Ì»¯ÔÚϵͳÄÚ²¿µÄϵͳÈí¼þ£¬¸ü¼ÓÁé»îºÍ¸öÐÔ»¯ Ó¦Óÿò¼Ü²ã: Java framework²ãÔ´Âë OS¶¨ÖÆ¿ª·¢ ΪӦÓò㿪·¢ÈËÔ±ÌṩAPI ϵͳÔËÐпâ²ã: CÓïÑÔ °üÀ¨CÓïÑÔ±ê×¼¿â,¶àýÌå¿â,OpenGL ES, SQLite, Webkit,DalvikÐéÄâ»úµÈ, ¸Ã²ãÊǶÔÓ¦Óÿò¼Ü²ãÌṩ֧³ÖµÄ²ã, Java·ÃÎÊÓ²¼þÐèͨ¹ýNDKʵÏÖ LinuxÄں˲ã: AndroidÊÇ»ùÓÚLinux2.6Äںˣ¬ÆäºËÐÄϵͳ·þÎñÈ簲ȫÐÔ¡¢ÄÚ´æ¹ÜÀí¡¢½ø³Ì¹ÜÀí¡¢Íø·ЭÒéÒÔ¼°Çý¶¯Ä£ÐͶ¼ÒÀÀµÓÚLinuxÄÚºË

DVMÓëJVMÇø±ð
http://yxwang0615.iteye.com/blog/947245
Çø±ðÒ»£ºdvmÖ´ÐеÄÊÇ.dex¸ñʽÎļþ jvmÖ´ÐеÄÊÇ.classÎļþ android³ÌÐò±àÒëÍêÖ®ºóÉú²ú.classÎļþ£¬È»ºó£¬dex¹¤¾ß»á°Ñ.classÎļþ´¦Àí³É.dexÎļþ£¬È»ºó°Ñ×ÊÔ´ÎļþºÍ.dexÎļþµÈ´ò°ü³É.apkÎļþ¡£apk¾ÍÊÇandroid packageµÄÒâ˼¡£ jvmÖ´ÐеÄÊÇ.classÎļþ¡£
Çø±ð¶þ:dvmÊÇ»ùÓڼĴæÆ÷µÄÐéÄâ»ú ¶øjvmÖ´ÐÐÊÇ»ùÓÚÐéÄâÕ»µÄÐéÄâ»ú¡£¼Ä´æÆ÷´æÈ¡ËٶȱÈÕ»¿ìµÄ¶à£¬dvm¿ÉÒÔ¸ù¾ÝÓ²¼þʵÏÖ×î´óµÄÓÅ»¯£¬±È½ÏÊʺÏÒƶ¯É豸¡£
Çø±ðÈý£º.classÎļþ´æÔںܶàµÄÈßÓàÐÅÏ¢£¬dex¹¤¾ß»áÈ¥³ýÈßÓàÐÅÏ¢£¬²¢°ÑËùÓеÄ.classÎļþÕûºÏµ½.dexÎļþÖС£¼õÉÙÁËI/O²Ù×÷£¬Ìá¸ßÁËÀàµÄ²éÕÒËÙ¶È

  1. ÕÆÎÕÈçºÎ´î½¨Android¿ª·¢»·¾³
    Ðè×¼±¸µÄ¹¤¾ßÓ뿪·¢°ü(32λ/64λ, Windows/Linux) : JDK eclipse ADT SDK 1) °²×°JDK ÅäÖû·¾³±äÁ¿(bin) 2) °²×°eclipse 3) eclipse°²×°ADT²å¼þ---ÀëÏß°²×°
    4) eclipseÖ¸¶¨SDKĿ¼ 5) ÅäÖÃSDK »·¾³±äÁ¿(toots , platform-tools) ×¢: Linux³£ÓòÙ×÷ϵͳ: Red Hat, Ubuntu
  2. ÕÆÎÕAndroidÏîĿĿ¼½á¹¹ 1.srcĿ¼£º src£¨¼´Source Code)£¬srcĿ¼ÓÃÀ´´æ·ÅÓ¦ÓóÌÐòÖÐËùÓеÄÔ´´úÂ룬´úÂëµÄÔ´ÎļþÒ»°ã´æ·ÅÔÚ¸ÃĿ¼ÏµÄÏàÓ¦µÄ°üÏ¡£ 2.genĿ¼£ºgenĿ¼£¬¸ÃĿ¼ÏÂÒ»°ãÖ»ÓÐÒ»¸ö Îļþ£¬¼´RÎļþ¡£¸ÃÎļþ¼ÐÏÂÃæÓиöR.javaÎļþ£¬R.javaÊÇÔÚ½¨Á¢ÏîĿʱ×Ô¶¯Éú³ÉµÄ£¬¶¨Òå¸ÃÏîÄ¿ËùÓÐ×ÊÔ´µÄË÷Òý¡£ 3.Android4.1Ŀ¼£º¸ÃÎļþ¼ÐÏ°üº¬android.jarÎļþ£¬ÕâÊÇÒ»¸öJava¹éµµÎļþ£¬ÆäÖаüº¬¹¹½¨Ó¦ÓóÌÐòËùÐèµÄËùÓеÄAndroid SDK¿â£¨ÈçViews¡¢Controls£©ºÍAPIs¡£ ͨ¹ýandroid.jar½«×Ô¼ºµÄÓ¦ÓóÌÐò°ó¶¨µ½Android SDKºÍAndroid Emulator£¬ÕâÔÊÐíÄãʹÓÃËùÓÐAndroidµÄ¿âºÍ°ü£¬ÇÒʹÄãµÄÓ¦ÓóÌÐòÔÚÊʵ±µÄ»·¾³Öе÷ÊÔ¡£ 4.assetsĿ¼£º ¸ÃĿ¼´æ·ÅÓ¦ÓóÌÐòÖÐʹÓõÄÍⲿ×ÊÔ´Îļþ£¬ÈçÉùÒô ÊÓƵµÈ£¬ÔÚAndroid³ÌÐòÖпÉÒÔͨ¹ýÊäÈë/Êä³öÁ÷¶Ô¸ÃĿ¼ÖеÄÎļþ½øÐжÁд¡£ 5.resĿ¼£º ¸ÃĿ¼ÓÃÀ´´æ·Å³ÌÐòÕâÓõ½µÄͼƬ¡¢½çÃæ²¼¾ÖÎļþ¼°XML¸ñʽµÄÃèÊöÎļþ¡£¸ÃĿ¼ÏÂÓжà¸öĿ¼¡£Ð½¨Ò»¸öAndroidÏîÄ¿£¬ÔÚresĿ¼ÏÂÒ»°ã »áÓÐ drawable,layout,valuseÈý¸öĿ¼¡£drawableÓÃÀ´´æ·ÅͼƬ×ÊÔ´,Ŀ¼ÏÂÒ»°ã»áÓÐÈý¸öĿ¼·Ö±ð´æ·Å¸ßÖеÍÈýÖÖ²»Í¬·Ö±æÂʵÄͼƬ£¬layoutĿ¼ÓÃÀ´´æ·ÅÓ¦ÓóÌÐòµÄ ½çÃæ²¼¾ÖÎļþ£¬valuesĿ¼Ï´æ·Å×Ö·û´®×ÊÔ´£¬ÑÕÉ«×ÊÔ´£¬Êý×é×ÊÔ´µÈXMLÎļþ¡£ 6.AndroidManifest.xml
  3. AndroidÖÐassetÎļþ¼ÐºÍrawÎļþ¼ÐÇø±ð£¿ ´ð£ºres/rawºÍassetsµÄÏàͬµã£º Á½ÕßĿ¼ÏµÄÎļþÔÚ´ò°üºó»áÔ­·â²»¶¯µÄ±£´æÔÚapk°üÖУ¬²»»á±»±àÒë³É¶þ½øÖÆ¡£ res/rawºÍassetsµÄ²»Í¬µã£º 1£©res/rawÖеÄÎļþ»á±»Ó³Éäµ½R.javaÎļþÖУ¬·ÃÎʵÄʱºòÖ±½ÓʹÓÃ×ÊÔ´ID¼´ R.raw.filename£»assetsÎļþ¼ÐϵÄÎļþ²»»á±»Ó³Éäµ½R.javaÖУ¬·ÃÎʵÄʱºòÐèÒªAssetManagerÀà¡£ 2£©res/raw²»¿ÉÒÔÓÐĿ¼½á¹¹£¬¶øassetsÔò¿ÉÒÔÓÐĿ¼½á¹¹£¬Ò²¾ÍÊÇassetsĿ¼Ï¿ÉÒÔÔÙ½¨Á¢Îļþ¼Ð 3£©¶ÁÈ¡Îļþ×ÊÔ´¾ÙÀý£º ¶ÁÈ¡res/rawϵÄÎļþ×ÊÔ´£¬Í¨¹ýÒÔÏ·½Ê½»ñÈ¡ÊäÈëÁ÷À´½øÐÐд²Ù×÷ InputStream is = getResources().openRawResource(R.raw.filename); ¶ÁÈ¡assetsϵÄÎļþ×ÊÔ´£¬Í¨¹ýÒÔÏ·½Ê½»ñÈ¡ÊäÈëÁ÷À´½øÐÐд²Ù×÷ AssetManager am = null; am = getAssets(); InputStream is = am.open("filename");
  4. ÕÆÎÕAndroidManifest.xml½á¹¹(Ó¦ÓóÌÐòÈë¿Ú) AndroidManifest.xml ÊÇÿ¸öandroid³ÌÐòÖбØÐëµÄÎļþ¡£ËüλÓÚÕû¸öÏîÄ¿µÄ¸ùĿ¼£¬ÃèÊöÁËpackageÖб©Â¶µÄ×é¼þ£¨activities,services, µÈµÈ£©£¬ËûÃǸ÷×ÔµÄʵÏÖÀ࣬¸÷ÖÖÄܱ»´¦Àí µÄÊý¾ÝºÍÆô¶¯Î»Öᣠ³ýÁËÄÜÉùÃ÷³ÌÐòÖеÄActivities, ContentProviders, Services,ºÍIntent Receivers,»¹ÄÜÖ¸¶¨permissionsºÍinstrumentation£¨°²È«¿ØÖƺͲâÊÔ£© AndroidManifest.xml½á¹¹ Android³ÌÐòÈë¿Ú: action½ÚµãÖеÄandroid.intent.action.MAIN±íÃ÷ËüËùÔÚµÄActivityÊÇÕû¸öÓ¦ÓóÌÐòµÄÈë¿Úµã
  5. ÕÆÎÕÄ£ÄâÆ÷µÄʹÓÃÒÔ¼°³£ÓÃadbÃüÁî 1. adb devices
    ²é¿´µ±Ç°Á¬½ÓÉ豸
  6. adb kill-server ÖÕÖ¹adb½ø³Ì
  7. adb start-server Æô¶¯adb½ø³Ì
  8. adb shell ½øÈëshellģʽ(Linuxģʽ),µ±Á¬½ÓÓжà¸öÉ豸ʱ,ÐèÖ´ÐÐÃüÁî adb -s É豸Ãû shell ×¢: ½øÈëshellģʽºóÐòÖ´ÐÐLinuxÃüÁî
  9. adb install apk·¾¶ °²×°apkÖÁÉ豸,µ±Á¬½ÓÓжà¸öÉ豸ʱ,ÐèÖ´ÐÐÃüÁî adb -s É豸Ãû install apk·¾¶ µ±É豸֮ǰװÓдÎapkʱ,Ìæ»»°²×°ÐòÖ´ÐÐÃüÁî adb install -r apk·¾¶
  10. adb uninstall ҪжÔصÄÓ¦ÓðüÃû жÔØÒÑ°²×°µÄÓ¦ÓÃ
  11. adb push Òª¿½±´µÄÎļþ·¾¶ É豸ÉÏ´æ·Å´ÎÎļþµÄ·¾¶ ½«Îļþ¿½±´ÖÁÉ豸sdcard,Èç adb push F:AndroidÊÚ¿Î×ÊÁÏÏîĿʵѵ1205Aapkcom.moluo.android_100111.apk /sdcard
  12. adb pull É豸ÉÏÎļþ·¾¶ µçÄÔ´æ·ÅÎļþ·¾¶ ½«Îļþ´ÓÉ豸¿½±´µ½µçÄÔ, Èç adb pull /sdcard/com.moluo.android_100111.apk E:/
  13. adb logcat ÃüÁîÐеķ½Ê½²é¿´ÈÕÖ¾ ÈôÏ£Íû½«ÈÕÖ¾±£´æÖÁijÎļþ, adb logcat -> E:/test.txt
  14. android list avd ²é¿´µ±Ç°´´½¨µÄËùÓÐÄ£ÄâÆ÷Áбí
  15. emulator @Ä£ÄâÆ÷Ãû×Ö Æô¶¯Ä³¸öÄ£ÄâÆ÷
  16. ÃüÁîÐвÙ×÷Êý¾Ý¿â adb shell cd data/data cd package cd databases /cd shared_prefs/ cd files sqlite3 test.db >.tables ¼´¿ÉÖ´ÐÐÏìÓ¦sqlÓï¾ä
  17. ÕÆÎÕActivityµÄÉúÃüÖÜÆÚ¼°¸÷·½·¨µ÷ÓÃʱ»ú ´ð£º¹²ÓÐÆ߸öÖÜÆÚº¯Êý£º void onCreate(Bundle savedInstanceState) µÚÒ»´Î´´½¨Ê±µ÷Óà void onStart() ±»Óû§¿É¼ûʱµ÷Óà void onRestart() µ±Activity´¦ÓÚstop״̬ÓÖ±»ÖØÐÂÆô¶¯Ê±µ÷Óà void onResume() µ±»ñµÃ½¹µã¼´¿ÉÓëÓû§½»»¥Ê±µ÷Óà void onPause() µ±Ê§È¥½¹µãʱµ÷Óà void onStop() µ±²»¿É¼ûʱµ÷Óà void onDestroy() µ±Ïú»Ùʱµ÷Óà Activity A---> Activity B, B½«AÍêÈ«¸²¸ÇʱÉúÃüÖÜÆÚµ÷ÓÃÁ÷³Ì: onPause(A) --> onCreate(B) --> onStart(B) --> onResume(B) --> onStop(A) ´Ëʱ°´"Back"°´¼ü,Ö¤Ã÷ÖÜÆÚµ÷ÓÃÁ÷³Ì onPause(B) --> onRestart(A) --> onStart(A) -->onResume(A) --> onStop(B) --> onDestroy(B) ×÷Òµ: ÆÁÄ»·½Ïò·¢Éú¸Ä±äʱÈçºÎÉúÃüÖÜÆÚ ? AndroidµÄ5¸ö½ø³ÌµÈ¼¶?
  18. ActivityËÄÖÖÆô¶¯Ä£Ê½ ÔÚAndroidManifest.xmlÇåµ¥ÎļþÖеıêÇ©ÖÐͨ¹ýandroid:launchModeÉèÖÃActivityÆô¶¯Ä£Ê½ standard ĬÈÏÖµ, ±íʾÔÚstartActivityʱ¼´´´½¨ÆäʵÀý singleTop Ê×Ïȼì²éÕ»¶¥ÊÇ·ñÓиÃActivityʵÀý,ÓÐÔð·µ»Ø,ÎÞÔð´´½¨ÆäʵÀý singleTask ¼ì²éÕû¸ö¶ÑÕ»ÓÐÎÞ¸ÃActivityʵÀý,ÓÐÔð·µ»Ø,ÎÞÔð´´½¨ÆäʵÀý singleInstance µ¥ÊµÀýģʽ, Ò»¸öActivityʵÀý¶ÀÏíÒ»¸öÈÎÎñ¶ÑÕ», ²¢ÇÒÖ»ÄÜÓÐÒ»¸ö¶ÑÕ»ÖÐÓиÃActivityµÄʵÀý
  19. AndroidManifest.xmlÇåµ¥Îļþ±êÇ©ÖÐÊôÐÔandroid:excludeFromRecents="true" android:screenOrientation="portrait" android:configChanges="orientation|locale"µÄº¬Òå ´ð: android:excludeFromRecents±íʾÊÇ·ñ¿É±»ÏÔʾÔÚ×î½ü´ò¿ªµÄactivityÁбíÀï,true±íʾ·ñ,false±íʾÊÇ android:screenOrientation±íʾactivityÏÔʾµÄģʽ, Ò»°ãÓÃÀ´ÉèÖÃactivityºáÆÁÏÔʾ(horizontal)»òÊúÆÁÏÔʾ(portrait) android:configChanges=[oneormoreof:"mcc""mnc""locale""touchscreen""keyboard""keyboardHidden""navigation""orientation""fontScale"] Êǵ±ËùÖ¸¶¨ÊôÐÔ(Configuration Changes)·¢Éú¸Ä±äʱ£¬Í¨Öª³ÌÐòµ÷Óà onConfigurationChanged()º¯Êý,±ÈÈçorientationÆÁÄ»·½Ïò·¢Éú¸Ä±ä,localeÓïÑÔ»·¾³·¢Éú¸Ä±äʱ
  20. ÈçºÎ½«Ò»¸öActivityÉèÖóɴ°¿ÚµÄÑùʽ ´ð£ºÔÚÇåµ¥ÎļþAndroidManifest.xmlÖÐÏàÓ¦µÄ±êÇ©ÄÚÉèÖÃÊôÐÔandroid:theme=”@android:style/Theme.Dialog”
  21. ActivityµÄ onSaveInstanceState() ºÍ onRestoreInstanceState() ´ð: ActivityµÄ onSaveInstanceState() ºÍ onRestoreInstanceState()²¢²»ÊÇÉúÃüÖÜÆÚ·½·¨£¬ËüÃDz»Í¬ÓÚ onCreate()¡¢onPause()µÈÉúÃüÖÜÆÚ·½·¨£¬ËüÃDz¢²»Ò»¶¨»á±»´¥·¢¡£µ±Ó¦ÓÃÓöµ½ÒâÍâÇé¿ö£¨È磺ÄÚ´æ²»×ã¡¢Óû§Ö±½Ó°´Home¼ü£©ÓÉϵͳÏú»ÙÒ»¸öActivityʱ£¬onSaveInstanceState() »á±»µ÷Óᣵ«Êǵ±Óû§Ö÷¶¯È¥Ïú»ÙÒ»¸öActivityʱ£¬ÀýÈçÔÚÓ¦ÓÃÖа´·µ»Ø¼ü£¬onSaveInstanceState()¾Í²»»á±»µ÷Óá£ÒòΪÔÚÕâÖÖÇé¿öÏ£¬Óû§µÄÐÐΪ¾ö¶¨Á˲»ÐèÒª±£´æActivityµÄ״̬¡£Í¨³£onSaveInstanceState()Ö»ÊʺÏÓÃÓÚ±£´æһЩÁÙʱÐÔµÄ״̬£¬¶øonPause()ÊʺÏÓÃÓÚÊý¾ÝµÄ³Ö¾Ã»¯±£´æ¡£ ÁíÍ⣬µ±ÆÁÄ»µÄ·½Ïò·¢ÉúÁ˸ı䣬 Activity»á±»´Ý»Ù²¢ÇÒ±»ÖØд´½¨£¬Èç¹ûÄãÏëÔÚActivity±»´Ý»ÙÇ°»º´æһЩÊý¾Ý£¬²¢ÇÒÔÚActivity±»ÖØд´½¨ºó»Ö¸´»º´æµÄÊý¾Ý¡£¿ÉÒÔÖØдActivityµÄ onSaveInstanceState() ºÍ onRestoreInstanceState()·½·¨¡£
  22. ÁоÙAndroidÖи÷ÖÖUIÌØЧ
    ´ð: Á½¸öActivityÇл»Ê±¶¯»­ÉèÖÃ: startActivityÖ®ºóµ÷ÓÃoverridePendingTransition(int enterAnim, intexitAnim)
    FragmentÇл»Ê±¶¯»­Ð§¹û
    ͼƬÂÖ²¥Ð§¹û: ͨ¹ýGalleryÅäºÏTimer¶¨Ê±Æ÷ʵÏÖ
    ÆÙ²¼Á÷Ч¹û:
    & ²à»¬²Ëµ¥:
    CoverFlow:
    Path²Ëµ¥:
    & ¹Ø¼ü×Ö·ÉÈë·É³öЧ¹û:
    ·­Ò³Ð§¹û:
    ViewPager:
    Fragment:
    ×Ô¶¨ÒåTabhost:
    ·¢±íÆÀÂÛͼÎÄ»ìÅÅ:

  23. ×Ô¶¨Òå×é¼þµÄʵÏÖ˼·
    ´ð: Android×Ô¶¨Òå×é¼þÓÐÈýÖÖʵÏÖ˼·:
    1) ¼Ì³Ðij¸öÏÖÓÐ×é¼þ£¬ÔÚÆä»ù´¡ÉÏÌí¼Ó¶îÍ⹦ÄÜ,Èç¼Ì³ÐGalleryʵÏÖCoverFlowЧ¹û
    2) ¸´ºÏÐÍ×é¼þ¶¨Òå: ¼Ì³Ðij¸öLayout£¬ÊµÏÖ¸´ºÏ×é¼þ×Ô¶¨Ò壬ÈçTextViewºÍEditText×éºÏʵÏֵǼע²á×é¼þ
    3) ¼Ì³ÐView£¬ÊµÏÖonDraw()·½·¨£¬ÊµÏÖ×Ô¼º»æÖÆ×é¼þ£¬È緭ҳЧ¹û×é¼þ

  24. ̸̸UIÖУ¬ PaddingºÍMarginÓÐʲôÇø±ð,gravityÓëlayout_gravityµÄÇø±ð
    ´ð£ºPadding ÓÃÀ´Ö¸¶¨×é¼þÄÚµÄÄÚÈݾàÀë×é¼þ±ß½çµÄ¾àÀë;
    MarginÓÃÀ´Ö¸¶¨¿Ø¼þÓë¿Ø¼þÖ®¼äµÄ¾àÀë
    GravityÓÃÀ´Ö¸¶¨×é¼þÄÚµÄÄÚÈÝÏà¶ÔÓÚ×é¼þ±¾ÉíµÄλÖÃ
    Layout_gravityÓÃÀ´Ö¸¶¨×é¼þÏà¶ÔÓÚÆ丸×é¼þµÄλÖÃ

  25. Äĸö×é¼þ¿ÉÒÔʵÏÖÊÖ·çÇÙЧ¹û£¬ÓÃÀ´ÊµÏÖÉèÖýçÃæµÄÀ࣬ʵÏÖ³éÌëЧ¹û, Ðü¸¡´°¿Ú£¿
    ´ð£ºÊµÏÖÊÖ·çÇÙЧ¹û£¨ExpandableListView£©
    ÉèÖýçÃæµÄÀࣨPreferenceActivity£©±£´æµ½sharedpreferenceÖÐ
    ³éÌëЧ¹û£¨slidingDrawer£©×é¼þ
    Ðü¸¡´°¿Ú: PopWindow,¿ÉÒÔʵÏÖÀàËÆDialogºÍ²Ëµ¥µÄЧ¹û

  26. listviewÓÅ»¯²ßÂÔ£¿
    ´ð£º1)¡¢×Ô¶¨ÒåAdapterµÄgetView(), ¶ÔconvetView½øÐÐÅпգ¬Êǵ±convertView²»Îª¿ÕµÄʱºòÖ±½ÓÖØÐÂʹÓÃconvertView
    ´Ó¶ø¼õÉÙÁ˺ܶ಻±ØÒªµÄViewµÄ´´½¨
    2)¶¨ÒåÒ»¸öViewHolder£¬½«convetViewµÄtagÉèÖÃΪViewHolder,²»Îª¿ÕʱÖØÐÂʹÓü´¿É
    3)¡¢µ±ListView¼ÓÔØÊý¾ÝÁ¿½Ï´óʱ¿ÉÒÔ²ÉÓ÷ÖÒ³¼ÓÔغÍͼƬÒì²½¼ÓÔØ

17.ListView·ÖÒ³¼ÓÔØʵÏÖ˼·£¿
ͨ³£ÊµÏÖ·ÖÒ³¼ÓÔØÓÐÁ½ÖÖ·½Ê½£¬Ò»ÖÖÊÇÔÚListViewµ×²¿ÉèÖÃÒ»¸ö°´Å¥£¬Óû§µã»÷¼´¼ÓÔØ¡£ÁíÒ»ÖÖÊǵ±Óû§»¬¶¯µ½µ×²¿Ê±×Ô¶¯¼ÓÔØ¡£
ÔÚListViewµ×²¿ÉèÖÃÒ»¸ö°´Å¥£¬Óû§µã»÷¼´¼ÓÔØʵÏÖ˼·:
// ¼ÓÉϵײ¿View£¬×¢ÒâÒª·ÅÔÚsetAdapter·½·¨Ç°
ListView.addFooterView(moreView);
bt.setOnClickListener(new OnClickListener() {

  1. @Override 
  2.        public void onClick(View v) { 
  3.            pg.setVisibility(View.VISIBLE);// ½«½ø¶ÈÌõ¿É¼û 
  4.            bt.setVisibility(View.GONE);// °´Å¥²»¿É¼û 
  5.  
  6.            handler.postDelayed(new Runnable() { 
  7.  
  8.                @Override 
  9.                public void run() { 
  10.                    loadMoreDate();// ¼ÓÔظü¶àÊý¾Ý 
  11.                    bt.setVisibility(View.VISIBLE); 
  12.                    pg.setVisibility(View.GONE); 
  13.                    mSimpleAdapter.notifyDataSetChanged();// Í¨ÖªlistViewË¢ÐÂÊý¾Ý 
  14.                } 
  15.  
  16.            }, 2000); 
  17.        } 
  18.    }); 



19.viewÓÐÄļ¸ÖÖ¸üз½Ê½µ±Óû§»¬¶¯µ½µ×²¿Ê±×Ô¶¯¼ÓÔØʵÏÖ˼·:
ʵÏÖOnScrollListener ½Ó¿ÚÖØдonScrollStateChanged ºÍonScroll·½·¨£¬Ê¹ÓÃonscroll·½·¨ÊµÏÖ”»¬¶¯“ºó´¦Àí¼ì²éÊÇ·ñ»¹ÓÐеļǼ£¬Èç¹ûÓÐ,Ìí¼Ó¼Ç¼µ½adapter, adapterµ÷Óà notifyDataSetChanged ¸üÐÂÊý¾Ý;Èç¹ûûÓмǼÁË£¬Ôò²»ÔÙ¼ÓÔØÊý¾Ý¡£Ê¹ÓÃonScrollStateChanged¿ÉÒÔ¼ì²âÊÇ·ñ¹öµ½×îºóÒ»ÐÐÇÒÍ£Ö¹¹ö¶¯È»ºóÖ´ÐмÓÔØ.
18.ListViewͼƬÒì²½¼ÓÔØʵÏÖ˼·£¿
1.ÏÈ´ÓÄڴ滺´æÖлñȡͼƬÏÔʾ£¨Äڴ滺³å£©
2.»ñÈ¡²»µ½µÄ»°´ÓSD¿¨Àï»ñÈ¡£¨SD¿¨»º³å£¬£¬´ÓSD¿¨»ñȡͼƬÊÇ·ÅÔÚ×ÓÏß³ÌÀïÖ´Ðеģ¬·ñÔò¿ìËÙ»¬ÆÁµÄ»°»á²»¹»Á÷³©£©
3.¶¼»ñÈ¡²»µ½µÄ»°´ÓÍøÂçÏÂÔØͼƬ²¢±£´æµ½SD¿¨Í¬Ê±¼ÓÈëÄÚ´æ²¢ÏÔʾ£¨ÊÓÇé¿ö¿´ÊÇ·ñÒªÏÔʾ£©

´ð: ÔÚÖ÷Ïß³Ì(UIÏß³Ì)¿ÉÒÔÖ±½Óµ÷ÓÃView.invalidate() ; ÔÚ×ÓÏß³ÌÐèÒª¸üÐÂUI¿ÉÒÔÖ±½Óµ÷ÓÃView.postInvalidate(),Ò²¿ÉÒÔͨ¹ýHandler·¢ËÍÏûÏ¢¸øÖ÷Ïß³Ì,È»ºóÔÚhandleMessage·½·¨ÖÐͨ¹ýView.invalidate() ¸üÐÂUI;»¹¿ÉÒÔÔÚ×ÓÏß³ÌÖÐÐèÒª¸üÐÂUIµÄʱºòµ÷ÓÃrunOnUIThread(Runnable )·½·¨,È»ºóÔÚ´Ë·½·¨ÖиüÐÂUI,ͬʱ¿ÉÒÔʹÓÃAsyncTaskÒì²½ÈÎÎñ, ÔÚdoInBackgroundÖ´ÐкÄʱ²Ù×÷, È»ºóÔÚonPostExcute·½·¨ÖÐÖ´ÐÐË¢ÐÂUI¶¯×÷
20. IntentµÄÔ­Àí£¬×÷Ó㬿ÉÒÔ´«µÝÄÄЩÀàÐ͵IJÎÊý£¿
´ð£ºintentÊÇÁ¬½ÓActivity, Service, BroadcastReceiver, ContentProviderËÄ´ó×é¼þµÄÐÅʹ,£¬¿ÉÒÔ´«µÝ°ËÖÖ»ù±¾Êý¾ÝÀàÐÍÒÔ¼°string, BundleÀàÐÍ£¬ÒÔ¼°ÊµÏÖÁËSerializable»òÕßParcelableµÄÀàÐÍ¡£
Intent¿ÉÒÔ»®·Ö³ÉÏÔʽÒâͼºÍÒþʽÒâͼ¡£
ÏÔʽÒâͼ£ºµ÷ÓÃIntent.setComponent()»òIntent.setClass()·½·¨Ã÷È·Ö¸¶¨ÁË×é¼þÃûµÄIntentΪÏÔʽÒâͼ£¬ÏÔʽÒâͼÃ÷È·Ö¸¶¨ÁËIntentÓ¦¸Ã´«µÝ¸øÄĸö×é¼þ¡£
ÒþʽÒâͼ£ºÃ»ÓÐÃ÷È·Ö¸¶¨×é¼þÃûµÄIntentΪÒþʽÒâͼ¡£ Androidϵͳ»á¸ù¾ÝÒþʽÒâͼÖÐÉèÖõĶ¯×÷(action)¡¢Àà±ð(category)¡¢Êý¾Ý£¨URIºÍÊý¾ÝÀàÐÍ£©ÕÒµ½×îºÏÊʵÄ×é¼þÀ´´¦ÀíÕâ¸öÒâͼ¡£

21.AndroidµÄËÄ´ó×é¼þÊÇʲô£¿ËüÃǵÄ×÷ÓÃÊÇʲô£¿
´ð:AndroidÓÐËÄ´ó×é¼þ£ºActivity¡¢Service¡¢Broadcast Receiver¡¢Content Provider¡£
Activity :Ó¦ÓóÌÐòÖУ¬Ò»¸öActivityͨ³£¾ÍÊÇÒ»¸öµ¥¶ÀµÄÆÁÄ»£¬ËüÉÏÃæ¿ÉÒÔÏÔʾһЩ¿Ø¼þÒ²¿ÉÒÔ¼àÌý²¢´¦ÀíÓû§µÄʼþ×ö³öÏìÓ¦¡£ActivityÖ®¼äͨ¹ýIntent½øÐÐͨÐÅ¡£
Service ·þÎñ:Ò»¸öService ÊÇÒ»¶Î³¤ÉúÃüÖÜÆڵģ¬Ã»ÓÐÓû§½çÃæµÄ³ÌÐò£¬¿ÉÒÔÓÃÀ´¿ª·¢Èç¼à¿ØÀà³ÌÐò¡£
BroadcastReceive¹ã²¥½ÓÊÕÆ÷:ÄãµÄÓ¦ÓÿÉÒÔʹÓÃËü¶ÔÍⲿʼþ½øÐйýÂËÖ»¶Ô¸ÐÐËȤµÄÍⲿʼþ(Èçµ±µç»°ºôÈëʱ£¬»òÕßÊý¾ÝÍøÂç¿ÉÓÃʱ)½øÐнÓÊÕ²¢×ö³öÏìÓ¦¡£¹ã²¥½ÓÊÕÆ÷ûÓÐÓû§½çÃ档Ȼ¶ø£¬ËüÃÇ¿ÉÒÔÆô¶¯Ò»¸öactivity»òserice À´ÏìÓ¦ËüÃÇÊÕµ½µÄÐÅÏ¢¡£
Content ProviderÄÚÈÝÌṩÕß :Ö÷ÒªÓÃÓÚ¶à¸öÓ¦ÓüäÊý¾Ý¹²Ïí¡£ÕâЩÊý¾Ý¿ÉÒÔ´æ´¢ÔÚÎļþϵͳÖлòSQLiteÊý¾Ý¿â¡£

  1. ÃèÊöÏÂServiceµÄÉúÃüÖÜÆÚ,ServiceÓÐÄÄЩÆô¶¯·½·¨£¬ÓÐʲôÇø±ð£¬ÔõÑùÍ£ÓÃService£¿ http://blog.csdn.net/huanyufeng/article/details/5873407 ´ð£ºServiceµÄÉúÃüÖÜÆÚ:onCreate, onStartCommand, onDestroy,onBindºÍonUnbind¡£ ͨ³£ÓÐÁ½ÖÖ·½Ê½Æô¶¯Ò»¸öService,ËüÃǶÔServiceÉúÃüÖÜÆÚµÄÓ°ÏìÊDz»Ò»ÑùµÄ¡£ 1) ͨ¹ýcontext.startService() onCreate-->onStartCommand-->onDestroy Service»á¾­Àú onCreate µ½ onStartCommand £¬È»ºó´¦ÓÚÔËÐÐ״̬£¬stopServiceµÄʱºòµ÷ÓÃonDestroy·½·¨¡£ Èç¹ûÊǵ÷ÓÃÕß×Ô¼ºÖ±½ÓÍ˳ö¶øûÓе÷ÓÃstopServiceµÄ»°£¬Service»áÒ»Ö±ÔÚºǫ́ÔËÐС£ Èç¹ûServiceÒѾ­Æô¶¯ÁË£¬µ±ÎÒÃÇÔÙ´ÎÆô¶¯Serviceʱ£¬²»»áÔÚÖ´ÐÐonCreate()·½·¨£¬¶øÊÇÖ±½ÓÖ´ÐÐ onStartCommand ()·½·¨¡£ 2) ͨ¹ýcontext.bindService() onCreate--> onBind--->onUnbind-->onDestroy Service»áÔËÐÐonCreate£¬È»ºóÊǵ÷ÓÃonBind£¬Õâ¸öʱºòµ÷ÓÃÕߺÍService°ó¶¨ÔÚÒ»Æð¡£µ÷ÓÃÕßÍ˳öÁË£¬Srevice¾Í»áµ÷ÓÃonUnbind->onDestroyed·½·¨¡£ Ëùν°ó¶¨ÔÚÒ»Æð¾Í¹²´æÍöÁË¡£µ÷ÓÃÕßÒ²¿ÉÒÔͨ¹ýµ÷ÓÃunbindService·½·¨À´Í£Ö¹·þÎñ£¬ÕâʱºòSrevice¾Í»áµ÷ÓÃonUnbind->onDestroyed·½·¨¡£ ×¢: onStartCommand()ÓÐËÄÖÖ·µ»ØÖµ: http://wenku.baidu.com/view/0c2b1af8910ef12d2af9e7b5.html START_STICKY£ºÈç¹ûservice½ø³Ì±»killµô£¬±£ÁôserviceµÄ״̬Ϊ¿ªÊ¼×´Ì¬£¬µ«²»±£ÁôµÝË͵Äintent¶ÔÏó¡£Ëæºóϵͳ»á³¢ÊÔÖØд´½¨service£¬ÓÉÓÚ·þÎñ״̬Ϊ¿ªÊ¼×´Ì¬£¬ËùÒÔ´´½¨·þÎñºóÒ»¶¨»áµ÷ÓÃonStartCommand(Intent,int,int)·½·¨¡£Èç¹ûÔÚ´ËÆÚ¼äûÓÐÈκÎÆô¶¯ÃüÁî±»´«µÝµ½service£¬ÄÇô²ÎÊýIntent½«Îªnull¡£ START_NOT_STICKY£º“·ÇÕ³ÐԵĔ¡£Ê¹ÓÃÕâ¸ö·µ»Øֵʱ£¬Èç¹ûÔÚÖ´ÐÐÍêonStartCommandºó£¬·þÎñ±»Òì³£killµô£¬ÏµÍ³½«»á°ÑËüÖÃΪstarted״̬£¬ÏµÍ³²»»á×Ô¶¯ÖØÆô¸Ã·þÎñ£¬Ö±µ½startService(Intent intent)·½·¨Ôٴα»µ÷ÓÃ;¡£ START_REDELIVER_INTENT£ºÖØ´«Intent¡£Ê¹ÓÃÕâ¸ö·µ»Øֵʱ£¬Èç¹ûÔÚÖ´ÐÐÍêonStartCommandºó£¬·þÎñ±»Òì³£killµô£¬ÏµÍ³»á×Ô¶¯ÖØÆô¸Ã·þÎñ£¬²¢½«IntentµÄÖµ´«Èë¡£ START_STICKY_COMPATIBILITY£ºSTART_STICKYµÄ¼æÈÝ°æ±¾£¬µ«²»±£Ö¤·þÎñ±»killºóÒ»¶¨ÄÜÖØÆô¡£
  2. AIDLµÄÈ«³ÆÊÇʲô£¿ÓÐʲôÑùµÄ¹¦ÄÜ? ´ð: AIDLÈ«³Æ: Android interface definition language(android½Ó¿Ú¶¨ÒåÓïÑÔ) , ¹¦ÄÜ: ÓÃÀ´¿ç½ø³ÌµÄ·ÃÎÊ·½·¨,¼´·ÃÎÊÔ¶³Ì·þÎñµÄ·½·¨ http://blog.csdn.net/stonecao/article/details/6425019 aidlʵÏֵIJ½Öè aidl¿ÉÒÔ´«µÝµÄÊý¾ÝÀàÐÍ 24.ÈçºÎ·ÀÖ¹AndroidÓ¦ÓÃÖеÄService±»ÏµÍ³»ØÊÕ? <·½°¸Ò»>: ͨ¹ýÉèÖÃsetForeground()ÌáÉýServiceÓÅÏȼ¶,½«ÆäÉèÖÃΪǰ̨½ø³Ì »òÕßͨ¹ýÔÚÇåµ¥ÎļþÖбêÇ©ÄÚͨ¹ýÉèÖÃandroid:priority="1000",ÌáÉýÆäÓÅÏȼ¶ <·½°¸¶þ>: ÔÚstartCommand()·½·¨Öзµ»ØSTART_STICKY»òSTART_REDELIVER_INTENTÔòServiceÏú»ÙÖ®ºó»áÖØÆô
  3. 25.ServiceÊÇ·ñÔËÐÐÔÚÖ÷Ïß³Ì,ServiceÓëActivityÊÇ·ñÔËÐÐÔÚͬһ¸öÏß³Ì? ServiceÓëActivityÓëBroadcastReceiverͬÑù¶¼ÔËÐÐÔÚUIÖ÷Ïß³Ì, Èç¹ûÓкÄʱ²Ù×÷¶¼»áÒý·¢ANRÎÊÌâ
  4. 26.IntentServiceµÄÓ÷¨ http://android.blog.51cto.com/268543/528166 http://blog.csdn.net/zhf198909/article/details/6906786 ÊÇServiceµÄ×ÓÀà,Ö÷ÒªÓÃÀ´½â¾öÔÚServiceÖд¦ÀíºÄʱ²Ù×÷. IntentServiceʹÓöÓÁеķ½Ê½½«ÇëÇóµÄIntent¼ÓÈë¶ÓÁУ¬È»ºó¿ªÆôÒ»¸öworker thread(Ïß³Ì)À´´¦Àí¶ÓÁÐÖеÄIntent£¬¶ÔÓÚÒì²½µÄstartServiceÇë Çó£¬IntentService»á´¦ÀíÍê³ÉÒ»¸öÖ®ºóÔÙ´¦ÀíµÚ¶þ¸ö£¬Ã¿Ò»¸öÇëÇ󶼻áÔÚÒ»¸öµ¥¶ÀµÄworker threadÖд¦Àí£¬²»»á×èÈûÓ¦ÓóÌÐòµÄÖ÷Ïß³Ì
  5. ×¢²á¹ã²¥Óм¸ÖÖ·½Ê½£¬ÕâЩ·½Ê½ÓÐʲôÌصãºÍÇø±ð? ´ð: µÚÒ»ÖÖ:ÔÚÇåµ¥ÎļþÖÐÉùÃ÷,Ìí¼Ó µÚ¶þÖÖʹÓôúÂë½øÐÐ×¢²áÈç: IntentFilter filter = new IntentFilter("android.provider.Telephony.SMS_RECEIVED"); IncomingSMSReceiver receiver = new IncomgSMSReceiver(); registerReceiver(receiver.filter); Á½ÖÖ×¢²áÀàÐ͵ÄÇø±ðÊÇ£º 1)µÚ¶þÖÖ²»Êdz£×¤Ð͹㲥£¬Ò²¾ÍÊÇ˵¹ã²¥¸úËæ³ÌÐòµÄÉúÃüÖÜÆÚ¡£ 2)µÚÒ»ÖÖÊdz£×¤ÐÍ£¬Ò²¾ÍÊÇ˵µ±Ó¦ÓóÌÐò¹Ø±Õºó£¬Èç¹ûÓÐÐÅÏ¢¹ã²¥À´£¬³ÌÐòÒ²»á±»ÏµÍ³µ÷ÓÃ×Ô¶¯ÔËÐС£

28.¹ã²¥µÄ·¢ËÍ·½Ê½ÓÐÄÄЩ
sendBroadcast(),sendOrderedBroadcast()ºÍsendStickyBroadcast()ÈýÖÖ
sendBroadcast()Õâ¸ö·½·¨µÄ¹ã²¥ÊÇÄܹ»·¢Ë͸øËùÓй㲥½ÓÊÕÕߣ¬°´ÕÕ×¢²áµÄÏȺó˳Ðò£¬Èç¹ûÄãÕâ¸öʱºòÉèÖÃÁ˹㲥½ÓÊÕÕßµÄÓÅÏȼ¶£¬ÓÅÏȼ¶Èç¹ûÇ¡ºÃÓë×¢²á˳ÐòÏàͬ£¬Ôò²»»áÓÐÈκÎÎÊÌ⣬Èç¹û˳Ðò²»Ò»Ñù£¬»á³öleaked IntentReceiver ÕâÑùµÄÒì³££¬²¢ÇÒÔÚÇ°ÃæµÄ¹ã²¥½ÓÊÕÕß²»Äܵ÷ÓÃabortBroadcast()·½·¨½«ÆäÖÕÖ¹£¬Èç¹ûµ÷Óûá³öBroadcastReceiver trying to return result during a non-ordered broadcastµÄÒì³££¬µ±È»£¬ÏȽÓÊÕµ½¹ã²¥µÄreceiver¿ÉÒÔÐ޸Ĺ㲥Êý¾Ý¡£
sendOrderedBroadcast()·½·¨¹ËÃû˼Òå¾ÍÊÇpriorityµÄÊôÐÔÄÜÆð×÷Ó㬲¢ÇÒÔÚ¶ÓÁÐÇ°ÃæµÄreceiver¿ÉÒÔËæʱÖÕÖ¹¹ã²¥µÄ·¢ËÍ¡£»¹ÓÐÕâ¸öapiÄÜÖ¸¶¨finalµÄreceiver£¬Õâ¸öreceiverÊÇ×îºóÒ»¸ö½ÓÊչ㲥ʱ¼äµÄreceiver£¬²¢ÇÒÒ»¶¨»á½ÓÊÕµ½¹ã²¥Ê¼þ£¬ÊDz»Äܱ»Ç°ÃæµÄreceiverÀ¹½ØµÄ¡£Êµ¼Ê×öʵÑéµÄÇé¿öÊÇÕâÑùµÄ£¬¼ÙÉèÎÒÓÐ3¸öreceiverÒÀÐòÅÅÁУ¬²¢ÇÒsendOrderedBroadcast()·½·¨Ö¸¶¨ÁËÒ»¸öfinalReceiver£¬ÄÇôintent´«µÝ¸øÕâ4¸öReceiverµÄ˳ÐòΪReceiver1-->finalReceiver-->Receiver2-->finalReceiver-->Receiver3-->finalReceiver¡£Õâ¸öÌØÐÔ¿ÉÒÔÓÃÀ´Í³¼ÆϵͳÖÐÄܼàÌýijÖֹ㲥µÄReceiverµÄÊýÄ¿¡£
sendStickyBroadcast()×ÖÃæÒâ˼ÊÇ·¢ËÍÕ³ÐԵĹ㲥£¬Ê¹ÓÃÕâ¸öapiÐèҪȨÏÞandroid.Manifest.permission.BROADCAST_STICKY,Õ³ÐԹ㲥µÄÌصãÊÇIntent»áÒ»Ö±±£Áôµ½¹ã²¥Ê¼þ½áÊø£¬¶øÕâÖֹ㲥ҲûÓÐËùνµÄ10ÃëÏÞÖÆ£¬10ÃëÏÞÖÆÊÇÖ¸ÆÕͨµÄ¹ã²¥Èç¹ûonReceive·½·¨Ö´ÐÐʱ¼äÌ«³¤£¬³¬¹ý10ÃëµÄʱºòϵͳ»á½«Õâ¸ö¹ã²¥ÖÃΪ¿ÉÒԸɵôµÄcandidate£¬Ò»µ©ÏµÍ³×ÊÔ´²»¹»µÄʱºò£¬¾Í»á¸ÉµôÕâ¸ö¹ã²¥¶øÈÃËü²»Ö´ÐС£
×¢: (ÏÂÃæÊǹ㲥½ÓÊÕÕßµÄÉúÃüÖÜÆÚÒÔ¼°Ò»Ð©Ï¸½Ú²¿·Ö£º
1.¹ã²¥½ÓÊÕÕßµÄÉúÃüÖÜÆÚÊǷdz£¶ÌÔݵģ¬ÔÚ½ÓÊÕµ½¹ã²¥µÄʱºò´´½¨£¬onReceive()·½·¨½áÊøÖ®ºóÏú»Ù
2.¹ã²¥½ÓÊÕÕßÖв»Òª×öһЩºÄʱµÄ¹¤×÷£¬·ñÔò»áµ¯³öApplication No Response´íÎó¶Ô»°¿ò
3.×îºÃÒ²²»ÒªÔڹ㲥½ÓÊÕÕßÖд´½¨×ÓÏß³Ì×öºÄʱµÄ¹¤×÷£¬ÒòΪ¹ã²¥½ÓÊÕÕß±»Ïú»Ùºó½ø³Ì¾Í³ÉΪÁË¿Õ½ø³Ì£¬ºÜÈÝÒ×±»ÏµÍ³É±µô
4.ºÄʱµÄ½Ï³¤µÄ¹¤×÷×îºÃ·ÅÔÚ·þÎñÖÐÍê³É)

29.¼òÊöAndroidÖеÄIPC»úÖÆ(½ø³Ì¼äµÄͨÐÅ»úÖÆ) IPC£¨Inter-Process Communication£¬½ø³Ì¼äͨÐÅ£©.
ÓÉÓÚandroidϵͳÖÐÓ¦ÓóÌÐòÖ®¼ä²»Äܹ²ÏíÄÚ´æ¡£ÔÚandroid SDKÖÐÌṩÁË4ÖÖÓÃÓÚ¿ç½ø³ÌͨѶµÄ·½Ê½¡£Õâ4ÖÖ·½Ê½ÕýºÃ¶ÔÓ¦ÓÚandroidϵͳÖÐ4ÖÖÓ¦ÓóÌÐò×é¼þ£ºActivity¡¢Content Provider¡¢BroadcastºÍService¡£ÆäÖÐActivity¿ÉÒÔ¿ç½ø³Ìµ÷ÓÃÆäËûÓ¦ÓóÌÐòµÄActivity£»Content Provider¿ÉÒÔ¿ç½ø³Ì·ÃÎÊÆäËûÓ¦ÓóÌÐòÖеÄÊý¾Ý£¨ÒÔCursor¶ÔÏóÐÎʽ·µ»Ø£©£¬µ±È»£¬Ò²¿ÉÒÔ¶ÔÆäËûÓ¦ÓóÌÐòµÄÊý¾Ý½øÐÐÔö¡¢É¾¡¢¸Ä²Ù ×÷£»Broadcast¿ÉÒÔÏòandroidϵͳÖÐËùÓÐÓ¦ÓóÌÐò·¢Ë͹㲥£¬¶øÐèÒª¿ç½ø³ÌͨѶµÄÓ¦ÓóÌÐò¿ÉÒÔ¼àÌýÕâЩ¹ã²¥£»ServiceºÍContent ProviderÀàËÆ£¬Ò²¿ÉÒÔ·ÃÎÊÆäËûÓ¦ÓóÌÐòÖеÄÊý¾Ý£¬µ«²»Í¬µÄÊÇ£¬Content Provider·µ»ØµÄÊÇCursor¶ÔÏ󣬶øService·µ»ØµÄÊÇJava¶ÔÏó£¬ÕâÖÖ¿ÉÒÔ¿ç½ø³ÌͨѶµÄ·þÎñ½ÐAIDL·þÎñ¡£
aidlÊÇ Android Interface definition languageµÄËõд£¬ËüÊÇÒ»ÖÖandroidÄÚ²¿½ø³ÌͨÐŽӿڵÄÃèÊöÓïÑÔ£¬Í¨¹ýËüÎÒÃÇ¿ÉÒÔ¶¨Òå½ø³Ì¼äµÄͨÐŽӿÚ.±àÒëÆ÷¿ÉÒÔͨ¹ýÀ©Õ¹ÃûΪaidlµÄÎļþÉú³ÉÒ»¶Î´úÂ룬ͨ¹ýÔ¤Ïȶ¨ÒåµÄ½Ó¿Ú´ïµ½Á½¸ö½ø³ÌÄÚ²¿Í¨ÐŽø³ÌµÄÄ¿µÄ.

30.ʲôÊÇANR ÈçºÎ±ÜÃâËü£¿£¨AndroidÏ̼߳äµÄͨÐÅ·½Ê½? £©
´ð£ºANR£ºApplication Not Responding(Ó¦ÓóÌÐòÎÞÏìÓ¦).µ±³öÏÖÏÂÁÐÇé¿öʱ£¬Android¾Í»áÏÔʾANR¶Ô»°¿òÁË£º ¶ÔÊäÈëʼþ£¨Èç°´¼ü¡¢´¥ÃþÆÁʼþ£©µÄÏìÓ¦³¬¹ý5Ãë ÒâÏò½ÓÊÜÆ÷£¨intentReceiver£©³¬¹ý10ÃëÖÓÈÔδִÐÐÍê±ÏAndroidÓ¦ÓóÌÐòÍêÈ«ÔËÐÐÔÚÒ»¸ö¶ÀÁ¢µÄÏß³ÌÖУ¨ÀýÈçmain£©¡£Õâ¾ÍÒâζ×Å£¬ÈκÎÔÚÖ÷Ïß³ÌÖÐÔËÐеģ¬ÐèÒªÏûºÄ´óÁ¿Ê±¼äµÄ²Ù×÷¶¼»áÒý·¢ANR¡£
½â¾ö·½°¸ÓÐÁ½ÖÖ:
1. AsyncTaskÒì²½ÈÎÎñÖУ¬doInBackground()ºÍonPostExecute(Result)Á½¸ö·½·¨·Ç³£ÖØÒª
doInBackground() Õâ¸ö·½·¨ÔËÐÐÔÚºǫ́Ïß³ÌÖУ¬Ö÷Òª¸ºÔðÖ´ÐÐÄÇЩºÜºÄʱµÄ²Ù×÷£¬ÈçÒƶ¯»¤ÀíϵͳÖеÄÍøÂçÁ¬½Ó¡¢½âÎöXMLµÈ²Ù×÷¡£¸Ã·½·¨±ØÐëÖØÔØ¡£
onPostExecute(Result) Õâ¸ö·½·¨Ò²ÔËÐÐÓÚUIỊ̈߳¬ÔÚdoInBackground(Params…)·½·¨Ö´Ðкóµ÷Ó㬸÷½·¨ÓÃÓÚ´¦Àíºǫ́ÈÎÎñÖ´Ðк󷵻صĽá¹û¡£
2. ×Óthread + handler

  1. HandlerµÄÔËÐлúÖÆ(ÔËÐÐÔ­Àí)(Handler,Looper,MessageQueue,Message,ThreadÖ®¼äµÄ¹Øϵ)
    Ò»¸öHandlerÔÊÐíÄã·¢Ëͺʹ¦ÀíMessageºÍRunable¶ÔÏó£¬Ã¿¸öÏ̶߳¼ÓÐ×Ô¼ºµÄLooper£¬Ã¿¸öLooperÖзâ×°×ÅMessageQueue¡£Looper¸ºÔ𲻶ϵĴÓ×Ô¼ºµÄÏûÏ¢¶ÓÁÐÀïÈ¡³ö¶ÓÍ·µÄÈÎÎñ»òÏûÏ¢Ö´ÐС£Ã¿¸öhandlerÒ²ºÍÏ̹߳ØÁª£¬Handler¸ºÔð°ÑMessageºÍRunable¶ÔÏ󴫵ݸøMessageQueue£¨Óõ½post £¬sendMessageµÈ·½·¨£©£¬¶øÇÒÔÚÕâЩ¶ÔÏóÀ뿪MessageQueueʱ£¬Handler¸ºÔðÖ´ÐÐËûÃÇ£¨Óõ½handleMessage·½·¨£©¡£
    ÆäÖÐMessageÀà¾ÍÊǶ¨ÒåÁËÒ»¸öÐÅÏ¢£¬Õâ¸öÐÅÏ¢Öаüº¬Ò»¸öÃèÊö·ûºÍÈÎÒâµÄÊý¾Ý¶ÔÏó£¬Õâ¸öÐÅÏ¢±»ÓÃÀ´´«µÝ¸øHandler.Message¶ÔÏóÌṩ¶îÍâµÄÁ½¸öintÓòºÍÒ»¸öObjectÓò¡£

  2. AsyncTaskµÄÖ÷Òª·½·¨ÓÐÄÄЩ?ÈçºÎÆô¶¯ºÍÍ£Ö¹AsyncTask?ÈçºÎÔÚAsyncTaskÖиüÐÂUI
    ´ð: AsyncTaskµÄÖ÷Òª·½·¨ÓÐdoInBackGround() ÔËÐÐÔÚºǫ́×ÓÏß³Ì,Ö´ÐкÄʱ²Ù×÷
    onPostExcute() ÔËÐÐÔÚUIÖ÷Ïß³Ì,ÓÃÓÚÖ´ÐÐË¢ÐÂUIµÄ´úÂë
    Æô¶¯Í¨¹ýexecute()·½·¨
    ֹͣͨ¹ýcancel(boolean flag)·½·¨È¡ÏûÖ´ÐÐ, ´«Èë²ÎÊýture±íʾÈç¹ûµ÷Ó÷½·¨Ê±Òì²½ÈÎÎñÕýÔÚÖ´ÐÐÔò´ò¶ÏÖ´Ðв¢È¡Ïû, Èç¹û´«false±íʾִÐÐÍê±ÏÔÙÈ¡Ïû
    Ë¢ÐÂUIµÄ´úÂëÒ»°ãжÔØonPostExcute()·½·¨ÖÐ
    33.AndroidÖеÄÎåÖÖ´æ´¢·½Ê½¼°ÆäÓ¦Óó¡¾°
    ´ð£º1)SharedPreferences

    ´æ´¢Â·¾¶:(data/data/packagename/shares_prefs), ÇáÁ¿¼¶´æ´¢,ÒÔ¼üÖµ¶ÔµÄÐÎʽ´æ´¢ÔÚxmlÖÐ,Ò»°ãÓÃÀ´±£´æÓ¦ÓÃÖеÄÉèÖÃÊôÐÔ
    2)Îļþ´æ´¢ SD¿¨´æ´¢¶àýÌåÎļþ, Îļþ»º´æ
    3) SqliteÊý¾Ý¿â ǶÈëʽ´æ´¢, ´æ´¢Â·¾¶:(data/data/packagename/databases), Ò»ÖÖǶÈëʽÊý¾Ý¿â,Ö§³ÖsqlÓïÑÔ,´æ´¢´óÁ¿½á¹¹ÐÔÊý¾Ý
    4)ContentProvider ½ø³Ì(Ó¦ÓóÌÐò)¼äÊý¾Ý¹²Ïí,Êý¾ÝÔ´¿ÉÒÔÊÇsqlite,Ò²¿ÉÒÔÊÇxml,Ïà¹ØÀà: ContentResolver(ÄÚÈݽâÎöÆ÷), ContentObserver(
    Êý¾Ý¹Û²ìÕß)
    5) ÍøÂç´æ´¢ ÌìÆøÊý¾ÝµÄxml,json¸ñʽµÈµÈ,ͨ¹ýHttpUrlConnection,HttpClient,»òÕßSOAPЭÒé»ñÈ¡Êý¾Ý

  3. AndroidÖеĶ¯»­API,¼°ÏîÄ¿ÖеÄÓ¦ÓÃ
    ´ð: AndroidÖÐÓÐÁ½ÖÖ¶¯»­, Ö¡¶¯»­ºÍ²¹¼ä¶¯»­,²¹¼ä¶¯»­ÓÖÓÐƽÒÆ,Ðýת,Ëõ·Å,½¥±ä¶¯»­
    3.0Ö®ºóÓÖÓÐÐÂÌØÐÔÊôÐÔ¶¯»­
    ÏîÄ¿ÖÐʹÓó¡¾°: ÏîÄ¿Æô¶¯Ïòµ¼¶¯»­, ActivityÇл»Ê±¶¯»­Ð§¹û(overriedPendingTransaction()),ÀàËÆTab±êǩҳѡÖÐÏî±³¾°µÄÇл», FragmentÇл»Ê±¶¯»­Ð§¹ûÉèÖÃ(setTransation()),
    ViewPager·­Ò³Ê±¶¯»­Ð§¹û
    ¶¯»­Ð§¹û²»¿ÉÒÔÔÚonCreate()·½·¨ÖÐÆô¶¯, ÒòΪ´Ëʱ´°¿ÚûÓÐÍêÈ«äÖȾ³É¹¦, ¿ÉÒÔÔÙonWindowFocusChanged()·½·¨ÖÐÆô¶¯¶¯»­

  4. ²¥·ÅÊÓƵÓÐÄÄЩʵÏÖ·½Ê½£¿
    ´ð£º1.ʹÓÃϵͳ×Ô´øµÄ²¥·ÅÆ÷À´²¥·Å£¬Ö¸¶¨ActionΪACTION_VIEW,DataΪUri£¬TypeΪÆäMIMEÀàÐÍ¡£
    //µ÷ÓÃϵͳ×Ô´øµÄ²¥·ÅÆ÷

    Intent intent = new Intent(Intent.ACTION_VIEW);

    intent.setDataAndType(uri, "video/mp4");

    startActivity(intent);

  5. ʹÓÃVideoView×é¼þÀ´²¥·Å, ¿ÉÒÔ½áºÏMediaControllerÀ´ÊµÏÖ²¥¿Ø, Ö»ÊDz»ÄÜËæÒâ¸ü¸ÄÊÓƵµÄ´óС¼°Î»Öá£

    1. ʹÓÃMediaPlayerºÍSurfaceViewÀ´ÊµÏÖ£¬ÕâÖÖ·½Ê½ºÜÁé»î,¿ÉÒÔ×Ô¶¨ÒåÊÓƵ²¥·ÅµÄ´óСºÍλÖá£
  6. ÈçºÎɨÃèSD¿¨ËùÓеĶàýÌå×ÊÔ´: ͼƬ, ÊÓƵ, ÒôƵ
    1). ͨ¹ýÎļþ¹ýÂË·½Ê½É¨Ãè(±ØÐëÖƶ¨ÏàÓ¦µÄºó׺)
    2). ͨ¹ýϵͳÌṩµÄContentProvider»ñÈ¡

    Ô­ÎĵØÖ·£º http://my.eoe.cn/1267335/archive/23184.html

http://www.aseoe.com/ true Android³£¼ûÎÊÌâ½â´ð http://www.aseoe.com/show-17-151-1.html report <£¿php echo strlen($content) / 2; ?> Á˽âAndroidϵͳ¼Ü¹¹ Ó¦Óòã: Java Ó¦Óÿª·¢¹¤³Ìʦ¿ª·¢µÄËùÓÐÓ¦ÓóÌÐò±ÈÈçµØͼ,ä¯ÀÀÆ÷,QQµÈÊôÓڸòã, ÊÖ»úÖеĶÌÐÅ,²¦ºÅ,ä¯ÀÀÆ÷µÈÕâЩӦÓóÌÐò¶¼ÊÇ¿ÉÒÔ±»¿ª·¢ÈËÔ±¿ª·¢µÄÆäËûÓ¦ÓóÌÐòËùÌæ»»£¬ Õâµã²»Í¬ÓÚÆäËû
TAG:
±¾Õ¾»¶Ó­ÈκÎÐÎʽµÄתÔØ£¬µ«ÇëÎñ±Ø×¢Ã÷³ö´¦£¬×ðÖØËûÈËÀͶ¯³É¹û
תÔØÇë×¢Ã÷£º ÎÄÕÂתÔØ×Ô£º°®Ë¼×ÊÔ´Íø http://www.aseoe.com/show-17-151-1.html

[Ç°¶Ë²å¼þÍƼö] Plugin

1 2 3 4
  • jQueryʵÏÖÖð×ÖÖð¾äÏÔʾ²å¼þl-by-l.min.js
  • jQuery´ø·½Ïò¸ÐÖªµÄÊó±ê»¬¹ýͼƬ±ß¿òÌØЧ²å¼þ
  • jQuery HotKeys¼àÌý¼üÅÌ°´ÏÂʼþkeydown²å¼þ
  • ÏìӦʽÎÞÏÞÂÖ²¥jQueryÐýתľÂí²å¼þ
ÏìӦʽÎÞÏÞÂÖ²¥jQueryÐýתľÂí²å¼þ
webÇ°¶Ë¿ª·¢
°®Ë¼×ÊÔ´Íø Copyright 2012-2014 Www.Aseoe.Com All rights reserved.(½úICP±¸13001436ºÅ-1)