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.


  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值