`
guzizai2007
  • 浏览: 354990 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

Activity1.1

 
阅读更多

An Activity is an application component that provides a screen with which users can interact in order to do something, such as dial the phone, take a photo, send an email, or view a map.

 

An application usually consists of multiple activities

 

Each time a new activity starts, the previous activity is stopped, but the system preserves the activity in a stack (the "back stack").

 

when the user is done with the current activity and presses the Back button, it is popped from the stack (and destroyed) and the previous activity resumes

 

activity's lifecycle callback methods

 

There are several callback methods that an activity might receive, due to a change in its state—whether the system is creating it, stopping it, resuming it, or destroying it—and each callback provides you the opportunity to perform specific work that's appropriate to that state change

 

To create an activity, you must create a subclass of Activity (or an existing subclass of it).

 

 

package com.cmge;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;

/**
 * @desc	一个简单的Activity
 * @author	ljt
 * @time	2014年8月24日 下午10:42:19
 */
public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }
    
}

 

 

The two most important callback methods are:

onCreate()

You must implement this method.

The system calls this when creating your activity

this is where you must call setContentView() to define the layout for the activity's user interface.

 

public void setContentView (View view)

Set the activity content to an explicit view. This view is placed directly into the activity's view hierarchy

 

onPause()

The system calls this method as the first indication that the user is leaving your activity 

This is usually where you should commit any changes that should be persisted beyond the current user session (because the user might not come back).

 

 

Declaring the activity in the manifest

You must declare your activity in the manifest file in order for it to be accessible to the system

 

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.cmge"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="19" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.cmge.MainActivity"
            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>

 Theandroid:name attribute is the only required attribute—it specifies the class name of the activity

 

Using intent filters

using the <intent-filter> element—in order to declare how other application components may activate it.

 

The <action> element specifies that this is the "main" entry point to the application. 

 

分享到:
评论
发表评论

文章已被作者锁定,不允许评论。

相关推荐

    NFC Activity Technical Specification 1.1.pdf

    This document specifies a communication protocol called the NFC Controller Interface (NCI) between an NFC Controller (NFCC) and a Device Host (DH).

    android mars视频代码 Activity Activity_03源码

    www.mars-droid.com/Android开发视频教程 代码 源码 mars老师讲课 android 视频源码 Activity_03 (在此特别感谢mars的无私奉献,此代码为跟随视频边学边做的)

    Android学习笔记-Activity篇

    Android学习笔记-Activity篇 Contents Android学习笔记-Activity篇 1 一、activity创建: 1 二、在manifest.xml中声明activity...1.1 定义launch模式 4 1.2 设置affinities 5 1.3 清空the back stack 5 1.4 开始task 5

    高通LA.1.1基线Android 管理 Activity和组件运行状态 的系统进程AMS

    高通LA.1.1基线Android内核系统开发-管理 Activity和组件运行状态 的系统进程----ActivityManagerServer(AMS)启动流程分析。该版本为Android 10 ,AMS的启动流程与旧版的不同。详细看文档内容。

    Android实现自定义手势和识别手势的功能

    1. 先完成自定义手势的Activity 1.1 因为需要存储手势文件所以需要声明权限: &lt;uses android:name=android.permission.READ_EXTERNAL_STORAGE&gt; //读取SD卡权限 ...

    安卓官网文档20210712-V1.1.rar

    2.版本说明:V1.1: 2.构建首个应用里面的 《5.启动另一个 activity _ Android 开发者 _ Android Developers》增添了java版本:《5.java编程-启动另一个 activity _ Android 开发者 _ Android Developers》

    【Android】Activity

    1.1. 设计并实现用户接口 衍生自 View 类的视图,控制 Activity 中特定的矩形空间,例如按钮 衍生自 ViewGroup 类的视图,是布局,例如线性布局 利用视图定义布局的最常见方法是借助保存在你的应用资源内的 XML 布局...

    android 开发技巧合集

    1.1、ANDROID 文件系统 7 1.2、ANDROID应用程序架构 9 2、ANDROID应用程序结构 11 2.1、ACTIVITY 12 2.1.1、概述 12 2.1.2、Activity的生命周期 15 2.1.3、Activity 的创建 16 2.1.4、Activity 的跳转(含Bundle传值...

    Android Activity之间的数据传递方法总结

    前言 在Activity间传递的数据一般比较简单,但是有时候实际开发中也会传一些比较复杂的数据,本节一起来学习更多Activity间数据的传递方法。 ...1.1、基本数据类型传递 String 不是基本数据类型,

    voice_activity_detection:基于深度学习和TensorFlow的语音活动检测

    语音活动检测项目 关键字:Python,TensorFlow,深度学习... 1.1基本安装 $ pip3 install -r requirements.txt $ pip3 install -e . 1.2虚拟环境安装 1.3 Docker安装 构建docker镜像: $ sudo make build (这可能

    hm1375_parrotv1.1验证通过_20170824_1528.7z

    全志R16的parrotv1.1的系统调通摄像头hm1375 2017/8/24 14:04 版本:V1.1 开发板:SC3817R OS:parrotv1.1(Android4.4.2) 1、 R:\wyb\hm1375_parrotv1.1\android\device\softwinner\astar-evb30\configs\camera....

    四大应用组件之Activity

     1.1. Intent:意图  显示意图: Intent(Context context,Class clazz)  功能: 启动Activity  1.2. 隐式意图: Intent(String action) 比如:分享选择、视频选择播放器、邮箱  注册了该action的App都可以启动...

    验证全志R18的LCD+HDMI双屏异显 ApiDemos.1.1.apk

    全志R18+全志R40验证OK!选择[APP] --&gt; [Activity] --&gt; [Presentation]

    IEEE Std 1012-2012 系统、软件测试与验证标准

    1.1 Scope 1 1.2 Purpose 2 1.3 Field of application 3 1.4 V&V objectives 4 1.5 Organization of the standard 4 1.6 Audience 6 1.7 Conformance 7 1.8 Disclaimer 7 2. Normative references 7 3. ...

    calculator

    import android.app.Activity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.EditText; public class CalculatorActivity extends Activity

    Video Activity Coder-开源

    Video Activity Coder 1.1 是一个基于桌面的程序,用 Java 创建,研究人员可以使用它来跟踪视频记录中的行为或事件。 此处包含基于 Windows 的安装文件,以及可用于非 Windows 操作系统的可执行 jar 文件。 根据 GNU...

    android学习文档

    1.1 第一种搭建Android的开发环境步骤: 12 1.2 第二种搭建Android的开发环境步骤: 12 2、AVD设备(模拟器) 13 3、Android的模拟器Emulator 14 4、DDMS调试 14 5、Android开发需知 14 5.1 Android目录结构 14 5.2 ...

    安卓毕业设计加源码-activity_manager_sys-android:活动管理系统-安卓端

    安卓毕业设计加源码 ...1.1 背景(Background) 该项目是本人的本科毕业设计作品,由本人负责全栈开发(),同时也旨在通过该项目熟悉多个 Android 主流框架的使用,所以也特意使用了如 Dagger 这样的框架(从项目

    Human-activity-recognition:使用移动传感器项目进行人类活动识别的基线分类器

    使用移动传感器识别人类活动该项目旨在学习和分类由分布在双臂上的多个移动加速度计记录的人类活动,使用活动识别数据集“Skoda Mini Checkpoint”(有关更多信息和... 最后一个稳定版本已经建立在 v1.1 下。当前数据:

    Activiti工作流使用手册操作文档

    Activiti工作流使用手册_acticiti工作流操作手册文档V1.1操作教程手册 解决java开发使用Activiti遇到的问题和使用组件的讲解

Global site tag (gtag.js) - Google Analytics