Android学习笔记:框架 - 应用程序原理1/5 - 综述

 



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语言编写。编译过的Java代码 — 包括程序所需的任何数据和资源文件 — 被AAPT TOOL捆绑进一个Android包,一个.apk后缀标识的压缩文件通过该文件将应用程序发布并安装到移动设备上;它就是用户下载到他们设备上的文件。所有的代码都在一个简单的.apk文件里,并被当作一个应用程序

不管怎么说,每个Android应用程序都生活在它自己的世界里:

  • 默认的,所有应用程序运行在自己的Linux进程里。当任何的应用程序代码需要执行时,Android将启动这些进程,当它不再被需要而且其他应用程序需要系统资源时,Android将结束该进程。
  • 每个进程有它自己的Java虚拟机,所以应用程序代码都是独立与其他所有应用程序代码运行的。
  • 默认的,每个应用程序都被指定了一个唯一的Linux用户ID。设置了权限,使该应用程序文件仅对该用户,该应用程序自己可见 — 尽管这儿也有方法将它们导入到其他应用程序里。

两个应用程序分享相同的用户ID也是可能的,在这种情况下它们将能看到对方的文件。为节约系统资源,拥有相同ID的应用程序也可以运行在相同的Linux进程里,分享相同的虚拟机。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值