当我安装一个Android应用程序究竟会发生什么? [英] What exactly happens when I install an android application?

查看:147
本文介绍了当我安装一个Android应用程序究竟会发生什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的猜测是,.apk文件包的内容都是在某处提取,应用程序注册在某个目录中,以便应用程序启动器或任何可以找到它。但是,是这样吗?如果是这样的话,是原来的manifest.xml每次读取该应用启动的时间或它得到$ P $对加工成某些其它形式的

My guess is that the contents of .apk package are extracted somewhere, and the application is registered at some directory so that the application launcher or whatever can find it. But is that all? If that is the case, is the original manifest.xml read every time the app is launched or it gets pre-processed into some other form?

推荐答案

这是 .apk文件 -file是不是不可思议的。这是该重新present一个Android应用程序的内容文件只是一个包。如果您在归档工具(如7Zip的)打开它,你可以在浏览器并提取它的内容。

Some basics

The .apk-file

An .apk-file is not magical at all. It's just a bundle of files which represent the content of an Android application. If you open it in a archive-tool (like 7Zip), you can browser and extract it's contents.

基本的Andr​​oid系统是一个Linux系统。 Android使用一个定制的Linux内核与省电和一些速度,改进了一些额外的功能。 Android设备的内部存储格式与 YAFFS2文件系统,充分采用了类似Linux的访问概念。

The basic Android-System is a Linux system. Android uses a custom Linux kernel with some extra functionality on power-saving and some speed-improvements. The internal storage of an Android device is formatted with the YAFFS2-filesystem, which fully features the Linux-like access-concepts.

在使用的文件系统可以通过制造或Android的版本有所不同。较新的设备通常使用 EXT3 ,而三星使用它自己的文件系统:的 RFS

The used file-system might differ by manufacture or Android-Version. Newer devices often use ext3, while Samsung uses it's own file-system: RFS

这是沙盒系统,这是由机器人的一个重要方面。

This is one important aspect of the Sandbox-system, which is used by Android.

嗯,首先它们通常由安装JDK实现编译。之后,他们被编译(以的.class -files),在 DX - 工具从Android SDK,然后交叉编译那些正常的Java类成的的Dalvik字节code 的。

Well, first they are normally compiled by an installed JDK implementation. After they are compiled (to .class-files), the dx-tool from the Android SDK then cross-compiles those "normal" java-classes into Dalvik-Bytecode.

这个特殊的基于Java code是那么的DVM(Dalvik虚拟机),它是基于开源JRE-实施的阿帕奇和谐

This "special" java-code is then interpreted by the DVM (Dalvik Virtual Machine), which is based on the opensource JRE-implementation Apache Harmony.

Android提供了对 /资产 -directory添加一些二进制的原始文件(例如SQLite数据库)。它们放入此目录中的文件的不是编译或优化。

Android offers the /assets-directory to add some binary raw-files (e.g. a SQLite Database). Files which are put into this directory are not compiled or optimized.

如果你把你的文件放到这个目录下,这是一种行为,你会期望从Android的。

If you put your files into this directory, this is the kind of behavior you would expect from Android.

/资产 -directory,你也可以把二进制文件(或其他方式)的原始档案在这里(如HTML的文件帮助页)。这些文件的编译/优化(如果可能)。

Like the /assets-directory, you can also put binary (or other) raw-files in here (e.g. HTML-files for the Help-page). These files are compiled/optimized (if possible).

的Andr​​oid的清单,也是其它XML的文件(布局,弦乐器,等等)存储和编译成二进制XML格式的。这是一个速度优化

The Android-Manifest and also the other XML-files (Layouts, Strings, etc.) are stored and "compiled" into a binary XML-format. This is a speed-optimization.

但从Android操作系统来看,一个应用程序拥有:

From Android OS point of view, a single Application owns:

  • 在它自己的过程中,
  • 在它自己的操作系统的用户(如在Linux上),
  • 在它自己的DVM,
  • 在它自己的地方堆和
  • 在它的文件系统上的自己的地方。

所以,是的,每一个Android应用程序有它自己的用户有适当的权限来访问它的位置在内部存储(这是由标准的Linux文件系统权限管理保护)和它自己的DVM-过程中(不能是从应用程序之外)进行访问。

So yes, every Android app has it's own user which has the proper rights to access it's place in the internal storage (which is protected by standard Linux filesystem rights-management) and it's own DVM-process (which can't be accessed from outside of the application).

要为应用程序留下的沙盒的可能性(例如连接到互联网),在Android清单中声明的​​权限使用。

To give the application the possibility to leave the Sandbox (e.g. to connect to the Internet), the permissions declared in the Android Manifest are used.

因此​​,从以上的解释,应该清楚当一个Android的应用程序安装会发生什么:

So from the above explanations, it should be clear what happens when an Android-Application is installed:

  1. 应用程序的创建新用户。
  2. 有了这个新的用户权限,在内部存储的应用程序,创建目录。
  3. 内容的 .apk文件 - 文件正在被抽取那里。
  4. 在Android的清单进行解析,并宣布意图过滤器 s的登记(如 android.intent.category.LAUNCHER 的筛选器的应用程序的标准入口点)。
  5. 现在,应用程序已经准备好为它的第一次发射。
  1. The new user for the Application is created.
  2. With this new users rights, the Applications directory in the internal storage is created.
  3. The contents of the .apk-file are being extracted there.
  4. The Android-Manifest is parsed and the declared intent-filters are registered (e.g. the android.intent.category.LAUNCHER-filter for the applications standard entry point).
  5. Now the application is ready for it's first launch.

这篇关于当我安装一个Android应用程序究竟会发生什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆