一步步深入了解android机制-1
来源:互联网 发布:淘宝35岁文艺女装店 编辑:程序博客网 时间:2024/05/18 01:15
首先,我们如果编写最简单的APP应用,比如hello world,只需要在oncreate函数中加入一下代码即可。
public class HelloWorld extends Activity {@Overridepublic void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); TextView tv = new TextView(this); tv.setText("Hello, World!"); setContentView(tv);}
那么,从点击应用到执行onCreate函数之间,android总共做了什么操作,在知道android的应用程序启动过程之前,我们需要知道android中launcher类的作用,它主要实现了主界面的一些操作,具体细节将在后续讨论。我们在主界面点击一个应用开始,就是执行了 launcher类的 onClick操作。
/** * Launches the intent referred by the clicked shortcut. * * @param v The view representing the clicked shortcut. */ public void onClick(View v) { // Make sure that rogue clicks don't get through while allapps is launching, or after the // view has detached (it's possible for this to happen if the view is removed mid touch). if (v.getWindowToken() == null) { return; } if (mWorkspace.isSwitchingState()) { return; } Object tag = v.getTag(); if (tag instanceof ShortcutInfo) { // Open shortcut final Intent intent = ((ShortcutInfo) tag).intent; int[] pos = new int[2]; v.getLocationOnScreen(pos); intent.setSourceBounds(new Rect(pos[0], pos[1], pos[0] + v.getWidth(), pos[1] + v.getHeight())); boolean success = startActivitySafely(intent, tag); if (success && v instanceof BubbleTextView) { mWaitingForResume = (BubbleTextView) v; mWaitingForResume.setStayPressed(true); } } else if (tag instanceof FolderInfo) { if (v instanceof FolderIcon) { FolderIcon fi = (FolderIcon) v; handleFolderClick(fi); } } else if (v == mAllAppsButton) { if (mState == State.APPS_CUSTOMIZE) { showWorkspace(true); } else { onClickAllAppsButton(v); } } }
0 0
- 一步步深入了解android机制-1
- 一步步深入了解View
- Android消息机制深入了解
- Android LayoutInflater原理分析,带你一步步深入了解View
- Android LayoutInflater原理分析,带你一步步深入了解View
- Android LayoutInflater原理分析,带你一步步深入了解View
- Android LayoutInflater原理分析,带你一步步深入了解View
- Android LayoutInflater原理分析,带你一步步深入了解View
- 深入了解android中的消息机制Handler
- Android 进阶学习:Android LayoutInflater原理分析,带你一步步深入了解View(一)
- Android 进阶学习:Android视图绘制流程完全解析,带你一步步深入了解View(二)
- Android 进阶学习:Android自定义View的实现方法,带你一步步深入了解View(四)
- Android 进阶学习:Android LayoutInflater原理分析,带你一步步深入了解View(一)
- Android 进阶学习:Android自定义View的实现方法,带你一步步深入了解View(四)
- Android 进阶学习:Android视图绘制流程完全解析,带你一步步深入了解View(二)
- 深入了解php底层机制(1)
- Memcached机制深入了解
- Android LayoutInflater原理分析,带你一步步深入了解View(一)
- 关于STK的各种报告Report
- 软件开发原则之依赖倒置原则
- ubuntu 上配置lua
- STL中map的使用
- OpenG: 简单的纹理贴图
- 一步步深入了解android机制-1
- 理解Python命名机制
- 买花瓶(简单动态规划DP)
- modelsim 10.1a安装与确解
- 让devexpress控件lookupedit绑定到实体属性
- 什么是网关
- ANR分析
- linux下apache的虚拟主机配置
- [LeetCode]Insertion Sort List