参考罗升阳《Android系统源代码情景分析》

在Android源码中,我们通常把实验性质的Android APP放在packages/experimental目录下。对于一个简单的应用程序,他的目录结构如下

Android应用程序工程一般包含有一个源代码目录src、一个资源目录res、一个配置文件AndroidManifest.xml和一个编译脚本文件Android.mk

HelloAndroid.java

package com.tian.hello;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log; public class HelloAndroid extends Activity {
private final static String LOG_TAG = "com.tian.hello.HelloAndroid"; @Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main); Log.i(LOG_TAG, "HelloAndroid Activity Created.");
}
}

main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/hello_android" >
</TextView>
</LinearLayout>

strings.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">HelloAndroid</string>
<string name="hello_android">Hello Android</string>
</resources>

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.tian.hello"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon"
android:label="@string/app_name">
<activity android:name=".HelloAndroid"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

Android.mk

LOCAL_PATH:= $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE_TAGS := optional

LOCAL_SRC_FILES := $(call all-subdir-java-files)

LOCAL_PACKAGE_NAME := HelloAndroid

include $(BUILD_PACKAGE)

源码中使用主题

android:theme="@android:style/Theme.Dialog

Android源码中添加APP的更多相关文章

  1. Android源码中添加C可执行程序

    在Android源码中添加C/CPP可执行程序一般保存在external目录中 下面是每个文件的内容 ①add.c #include "add.h" int add (int a, ...

  2. 关于android源码中的APP编译时引用隐藏的API出现的问题

    今天在编译android源码中的计算器APP时发现,竟然无法使用系统隐藏的API,比如android.os.ServiceManager中的API,引用这个类时提示错误,记忆中在android源码中的 ...

  3. 导入android源码中的APP源码到eclipse

    导入android源码中的APP源码到eclipse 一般最简单的办法就是创建新的android工程,选择create project from existing source选项,直接导入源码就OK ...

  4. 在Android 源码中添加系统服务

    Android系统本身提供了很多系统服务,如WindowManagerService,PowerManagerService等.下面描述一下添加一个系统服务的具体步骤. 1.定义自定义系统服务接口 撰 ...

  5. Eclipse与Android源码中ProGuard工具的使用

    由于工作需要,这两天和同事在研究android下面的ProGuard工具的使用,通过查看android官网对该工具的介绍以及网络上其它相关资料,再加上自己的亲手实践,算是有了一个基本了解.下面将自己的 ...

  6. Eclipse与Android源码中ProGuard工具的使用(代码混淆)

    由于工作需要,这两天和同事在研究android下面的ProGuard工具的使用,通过查看android官网对该工具的介绍以及网络上其它相关资料,再加上自己的亲手实践,算是有了一个基本了解.下面将自己的 ...

  7. 访何红辉:谈谈Android源码中的设计模式

    最近Android 6.0版本的源代码开放下载,刚好分析Android源码的技术书籍<Android源码设计模式解析与实战>上市,我们邀请到它的作者何红辉,来谈谈Android源码中的设计 ...

  8. android studio应用修改到android源码中作为内置应用

    1. 方法一:导入,编译(太麻烦,各种不兼容问题) android studio和eclipse的应用结构目录是不同的,但是在android源码中的应用基本上都是使用的eclipse目录结构(在/pa ...

  9. Android源码中的FLAG为何使用16进制

    1.在阅读源码的时候经常发现有一些标志属性使用一些位操作来判断是否具有该标志,增加标志或者去除标志. 比如View.java中的 /** * This view does not want keyst ...

随机推荐

  1. 升级pip3后出现importerror:cannot import name main

    在ubuntu中,升级了pip3,再次使用pip3安装相关的python包的时候就出现以下错误 ImportError: cannot import name main 解决:pip3文件在/usr/ ...

  2. Java进阶学习:JSON解析利器JackSon

    Java:JSON解析利器JackSon JackSon基础 1.Maven项目引入 <!-- https://mvnrepository.com/artifact/org.codehaus.j ...

  3. Java实现将一段汉字变成unicode码

    public class T { public static void main(String[] args) { String s = "java 中文编码"; System.o ...

  4. Thread.currentThread().getContextClassLoader() and Class.getClassLoader()

    Thread.currentThread().getContextClassLoader() and Class.getClassLoader()   一.同一工程中: String path = T ...

  5. selenium主要功能封装

    最近实习需要使用selenium这一自动化工具对公司的运维监控系统进行自动化爬取数据,编写代码过程中负责带我的杰哥让我参考借鉴他们公司外包的运维监控系统代码,在项目中我看到了对selenium主要各功 ...

  6. 【leetcode刷题笔记】3Sum Closest

    Given an array S of n integers, find three integers in S such that the sum is closest to a given num ...

  7. JsonSchema使用详解

    JSON Schema是一个用于验证JSON数据结构的强大工具, 我查看并学习了JSON Schema的官方文档, 做了详细的记录, 分享一下. 我们可以使用JSON Schema在后续做接口测试中做 ...

  8. linux常见命令2

    systemctl set-hostname HOSTNAME  在centos7上设置主机名,永久有效 curl -O -L http://www.gnu.org/software/gettext/ ...

  9. CSS3分享功能

    [代码][CSS]代码  $.fn.share = function(opts) {  var $body, $head;  if ($(this).length === 0) {    consol ...

  10. java 中的拦截器和过滤器

    区别: 1.拦截器是基于java的反射机制的,而过滤器是基于函数回调 2.过滤器依赖与servlet容器,而拦截器不依赖与servlet容器 3.拦截器只能对action请求起作用,而过滤器则可以对几 ...