Android_1

偶对Android比较有兴趣,不过这方面的资料比较少。所以我直接看google提供的资料。一方面一个人看难以理解,一方面也学着写读书笔记。主要是方便向大家请教。

我是从头开始的,一开始是讨论框架的。下面是原文。

Android applications are written in the Java programming language. The compiled Java code — along with any data and resource files required by the application — is bundled by the aapt tool into an Android package, an archive file marked by an .apk suffix. This file is the vehicle for distributing the application and installing it on mobile devices; it's the file users download to their devices. All the code in a single .apk file is considered to be one application.

In many ways, each Android application lives in its own world:

  • By default, every application runs in its own Linux process. Android starts the process when any of the application's code needs to be executed, and shuts down the process when it's no longer needed and system resources are required by other applications.
  • Each process has its own Java virtual machine (VM), so application code runs in isolation from the code of all other applications.
  • By default, each application is assigned a unique Linux user ID. Permissions are set so that the application's files are visible only that user, only to the application itself — although there are ways to export them to other applications as well.

It's possible to arrange for two applications to share the same user ID, in which case they will be able to see each other's files. To conserve system resources, applications with the same ID can also arrange to run in the same Linux process, sharing the same VM.

我的理解是:Android上的程序是用Java写的,后缀名是.apk. 后面其说明了在默认情况下,每个程序都是运行在它自己的Linux进程下(我不理解“runs in its own Linux process”这句话的确切的含义是什么。)后面似乎好理解,如果要运行程序,自然要先启动进程。如果程序不需要再使用,或者系统资源不够的时候,Android 都会关闭掉这个程序的进程。(进程是什么?)

继续:每个进程都会有一个独立的Java 虚拟机,从而任何一个程序都会隔离于其他程序运行(这样理解对吗?为什么要这么做?是不是为了系统稳定考虑?还是为了安全?)

继续看:每个程序都拥有一个唯一的Linux用户帐号(这里的意思是不是相当于每一个应用程序都作为一个独立的用户。干嘛要这样做?感觉挺浪费的。)接下来,文章里说,对这些程序都设定了权限,使得其只对用户(或应用程序本身)是“可见的”(觉得这样的话是废话,自己怎么可能对自己不“可见”呢?另外:这里可见如何理解?是不是可以理解为可以调用程序提供的方法和程序的资源?)然后继续说明了还是有办法让别的程序来共享这个程序的资源的。

最后:说两个程序可以拥有同样的用户ID,目的是可以共享对方的文件。并且为了节约系统资源,这两个程序是使用相同的Linux进程,相同的虚拟机。

评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值