您的位置 首页 发布

Android 结构简介

======================= 第一节 ===========================这里简单的介绍了Android的java环境基础,在后面一节中会结合具体的实例来理解这一节

======================= 第一节 ===========================

这儿简略的介绍了Android的java环境根底,在后面一节中会结合详细的实例来了解这一节的内容。

一、Dalvik虚拟机

Dalvik是Android的程序的java虚拟机,代码在dalvik/下,

./

|– Android.mk

|– CleanSpec.mk

|– MODULE_LICENSE_APACHE2

|– NOTICE

|– README.txt

|– dalvikvm 虚拟机的完成库

|– dexdump

|– dexlist

|– dexopt

|– docs

|– dvz

|– dx

|– hit

|– libcore

|– libcore-disabled

|– libdex

|– libnativehelper 运用JNI调用本地代码时用到这个库

|– run-core-tests.sh

|– tests

|– tools

`– vm

二、Android的java结构

Android层次中第3层是java结构,第四层便是java使用程序。

Android的java类代码,首要是在frameworks/base/core/java/下,

./

|– Android

|– com

|– jarjar-rules.txt

`– overview.html

咱们再看一下frameworks/base/目录

./

|– Android.mk

|– CleanSpec.mk

|– MODULE_LICENSE_APACHE2

|– NOTICE

|– api

|– awt

|– build

|– camera

|– cmds

|– common

|– core

|– data

|– docs

|– graphics

|– include

|– keystore

|– libs

|– location

|– media

|– native

|– obex

|– opengl

|– packages

|– preloaded-classes

|– sax

|– services

|– telephony

|– test-runner

|– tests

|– tools

|– vpn

`– wifi

这儿也有Android的java结构代码。

三、JNI

在Android中,经过JNI,java能够调用C写的代码,首要的完成是在frameworks/base/core/jni,经过检查Android.mk,咱们能够看到最终生成了libandroid_runtime.so,详细完成JNI功用需求上面咱们介绍的libnativehelper.so,

四、体系服务之java

1、binder,供给Android的IPC功用

2、servicemanager,服务办理的服务器端

3、体系进程zygote,担任孵化一切的新使用

======================= 第二节 ==========================

在我平常工作中首要是进行linux网络子体系的模块开发、linux使用程序(C/C++)开发。在学习和从事驱动模块开发的过程中,假如你对linux体系自身,包含使用程序开发都不了解,那么读内核代码就好像天书,毫无意义,所以我剖析结构也是从根本体系api开端的,当然也不会太多涉及到使用程序开发。

好,开端这节首要是讲一个简略的adnroid使用程序,从使用程序动身,到结构代码。

剖析的使用程序咱们也奉行拿来主义:froyo/development/samples/HelloActivity

./

|– Android.mk

|– AndroidManifest.xml

|– res

|– src

`– tests

其他的就多说了,看代码

/**

* Copyright (C) 2006 The Android Open Source Project

*

* Licensed under the Apache License, Version 2.0 (the License);

* you may not use this file except in compliance with the License.

* You may obtain a copy of the License at

*

* http://www.apache.org/licenses/LICENSE-2.0

*

* Unless required by applicable law or agreed to in writing, software

* distributed under the License is distributed on an AS IS BASIS,

* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and

* limitations under the License.

*/

package Android.util;

import com.Android.internal.os.RuntimeInit;

import java.io.PrintWriter;

import java.io.StringWriter;

/**

* API for sending log output.

*

*

Generally, use the Log.v() Log.d() Log.i() Log.w() and Log.e()

* methods.

*

*

The order in terms of verbosity, from least to most is

* ERROR, WARN, INFO, DEBUG, VERBOSE. Verbose should never be compiled

* into an application except during development. Debug logs are compiled

* in but stripped at runtime. Error, warning and info logs are always kept.

*

*

Tip: A good convention is to declare a TAG constant

* in your class:

*

*

private static final String TAG = MyActivity;

*

* and use that in subsequent calls to the log methods.

*

*

*

Tip: Don’t forget that when you make a call like

*

Log.v(TAG, index= + i);

* that when you’re building the string to pass into Log.d, the compiler uses a

* StringBuilder and at least three allocations occur: the StringBuilder

* itself, the buffer, and the String object. Realistically, there is also

* another buffer allocation and copy, and even more pressure on the gc.

* That means that if your log message is filtered out, you might be doing

声明:本文内容来自网络转载或用户投稿,文章版权归原作者和原出处所有。文中观点,不代表本站立场。若有侵权请联系本站删除(kf@86ic.com)https://www.86ic.net/changshang/fabu/323665.html

为您推荐

联系我们

联系我们

在线咨询: QQ交谈

邮箱: kf@86ic.com

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

返回顶部