Something about Android

Android程序的入口點:

很多初入Android開發的網頁可能不知道Android程序的入口點是什麼,不是main()嗎,很多網友可能直接回復是onCreate,當然我相信回覆onCreate的在字面上不算錯,但是你們想的是Activity中的onCreate方法吧,這裏告訴下大家真正的入口點entrypoint是什麼。

    Android使用GoogleDalvik VM,相對於傳統JavaVM而言有着很大的不同,在Sun的Java體系中入口點和標準c語言一樣是main(),而每個Android程序都包含着一個Application實例,一個Application實例中有多個Activity、Service、ContentProvider或BroadcastReceiver。因爲大部分的應用都包含Activity所以,說很多網友認爲是Activity的onCreate,但是你沒有發現你的工程中有多個Activity嗎? 你可能沒有見過沒有Activity的Android應用吧。

    其實在android.app.Application這個包的onCreate纔是真正的Android入口點,只不過大多數開發者無需重寫該類,他的繼承關係如下圖:
 

java.lang.Object

↳ android.content.Context

↳android.content.ContextWrapper

↳android.app.Application 

android.app.Application類包含了4個公開的方法 

void  onConfigurationChanged(ConfigurationnewConfig)
 

void  onCreate() //這裏纔是真正的入口點。

void  onLowMemory()

void  onTerminate()

    所以希望大家,記住真正的Android入口點是application的main,你可以看下androidmanifest.xml的包含關係就清楚了,並不是每個應用都必須有Activity的。

xmlns:android

    xmlns:android。是一個XML命名空間,告訴Android開發工具你準備使用Android命名空間裏的一些通用屬性。在所有Android XML設計文件中最外層的標記必須使用這個樹形。它可以提示你輸入什麼,不該輸入什麼,什麼是對的,什麼是錯的,也可以理解爲語法文件。或者語法判斷器什麼的。



Activity:

    當前Activity只能有一個處於活動狀態,可以通過intent方法進行切換,另外每個activity需要在Androidmainfest中進行配置。
    通過activity在Androidmainfest的設置,可以設置當屏幕旋轉時調用方法(事件),而不是重啓程序。

ADT安裝錯誤:

Cannot complete the install becauseone or morerequired items could not be found. Software being installed:Android NativeDevelopment Tools 20.0.0.v201206242043-391819(com.android.ide.eclipse.ndk.feature.group20.0.0.v201206242043-391819) Missingrequirement: Android Native DevelopmentTools 20.0.0.v201206242043-391819(com.android.ide.eclipse.ndk.feature.group20.0.0.v201206242043-391819) requires'org.eclipse.cdt.feature.group 0.0.0' butit could not be found.

錯誤信息如上,用indigo3.7.2還是使用juno4.2都是這個錯誤。

PS,我是用的jee的eclipse,安裝adt18、adt19都沒問題。發佈新的adt20就有問題了。

CDT丟失,看來肯定是Eclipse的插件了。

http://www.eclipse.org/cdt/然後下載安裝,

http://mirror.bjtu.edu.cn/eclipse/tools/cdt/releases/juno/r/cdt-master-8.1.0.zip

NDT是幹啥的,是使用C代碼來寫android應用的,Eclipseg官網提供版本不帶的。要自己安裝插件。增加對C的支撐,提高程序速度效率。

其實在eclipse裏available software site中也可以找到對應的網址。


模擬器:

•Intel VirtualizationTechnology (VT, VT-x, vmx) extensions

•AMD Virtualization(AMD-V, SVM) extensions (only supported forLinux)

 

Note: Virtualizationextensions are typicallyenabled through your computer's BIOS and are frequentlyturned off by default.Check the documentation for your system's motherboard tofind out how to enablevirtualization extensions.所以有時候安裝IntelHaxm未完全成功時,需要在開機時進入BIOS進行設置。

Tip:最新版的Android模擬器加速器,有的機子可能不支持

SDKManager:

Android sdk manager 顯示 “Done loading packages”,停下來不動了

鏈接斷了!!這個很正常!!我也是經常更新不了追問那怎麼樣纔可以更新!? 有人說 在SDK Manager下Tools->Options打開了SDK Manager的Settings,選中“Force https://… sources to befetched usinghttp://…”,強制使用http協議。


Jad,JadClipse安裝

Installation:

Put the JadClipse JAR file into the plugins folderof your Eclipse installation.

RestartEclipse (eclipse -clean).

Get Jad.

Put the Jad executable into a directory that is inthe execution path of your operating system.

Alternatively, you can configure the path to the Jadexecutable underWindow > Preferences... > Java > JadClipse > Pathto Decompiler.(Set the full path, e.g. C:\Program Files\Jad\jad.exe)

Go to Window >Preferences... > General >Editors > File Associations and make sure that the JadClipse Class FileViewer has the default file association for*.class files.


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章