android基本知识(一)
1)我们来谈谈android.intent.category.DEFAULT的用途。
Intent intent = new Intent(MainActivity.this,SecondActivity.class);startActivity(intent);
Intent intent2 = new Intent("com.example.intenttest.ACTION_START");intent2.addCategory("com.example.intenttest.MY_CATEGORY");startActivity(intent);
<activityandroid:name=".SecondActivity"android:label="@string/app_name"><intent-filter ><action android:name="com.example.intenttest.ACTION_START"/><category android:name="android.intent.category.DEFAULT"/><category android:name="com.example.intenttest.MY_CATEGORY"/></intent-filter></activity>
Intent intent = new Intent(MainActivity.this,SecondActivity.class);startActivityForResult(intent,1);
Intent intent = new Intent();intent.putExtra("extra_data", "我返回数据了");setResult(RESULT_OK, intent);finish();
@Overrideprotected void onActivityResult(int requestCode, int resultCode, Intent data) {switch (requestCode) {case 1:if(RESULT_OK == resultCode){String extra_data = data.getStringExtra("extra_data");Log.i("extra_data",extra_data);}break;default:break;}};

public class MainActivity extends ActionBarActivity {@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);requestWindowFeature(Window.FEATURE_NO_TITLE);setContentView(R.layout.activity_main);Log.i("Life Tag", "OnCreate");Button normalButton = (Button)findViewById(R.id.normal_button);Button dialogButton = (Button)findViewById(R.id.dialog_button);EditText tempText = (EditText)findViewById(R.id.login_name);if(null != savedInstanceState){//利用Bundle对象来还原之前在内存回收活动时,保存的关键数据String tempData = savedInstanceState.getString("tempName");Log.i("Tag", tempData);tempText.setText(tempData);}//测试安卓活动的七个生命周期,利用对话框活动和完全覆盖活动来区别onPause和onStop方法normalButton.setOnClickListener(new OnClickListener() {@Overridepublic void onClick(View v) {// TODO Auto-generated method stubIntent intent = new Intent(MainActivity.this,NormalActivity.class);startActivity(intent);}});dialogButton.setOnClickListener(new OnClickListener() {@Overridepublic void onClick(View v) {// TODO Auto-generated method stubIntent intent = new Intent(MainActivity.this,DialogActivity.class);startActivity(intent);}});}@Overrideprotected void onStart() {// TODO Auto-generated method stubsuper.onStart();Log.i("Life Tag", "onStart");}@Overrideprotected void onResume() {// TODO Auto-generated method stubsuper.onResume();Log.i("Life Tag", "OnResume");}@Overrideprotected void onPause() {// TODO Auto-generated method stubsuper.onPause();Log.i("Life Tag", "OnPause");}@Overrideprotected void onStop() {// TODO Auto-generated method stubsuper.onStop();Log.i("Life Tag", "onStop");}@Overrideprotected void onDestroy() {// TODO Auto-generated method stubsuper.onDestroy();Log.i("Life Tag", "onDestroy");}@Overrideprotected void onRestart() {// TODO Auto-generated method stubsuper.onRestart();Log.i("Life Tag", "OnRestart");}//在内存不足时回收活动,保存其主要关键数据,这在用户体验还是比较重要的了。@Overrideprotected void onSaveInstanceState(Bundle outState) {// TODO Auto-generated method stubsuper.onSaveInstanceState(outState);EditText tempText = (EditText)findViewById(R.id.login_name);String name = tempText.getText().toString();outState.putString("tempName", name);Log.i("Name_Tag", name);}

protected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);Button secondButton = (Button)findViewById(R.id.secondButton);Log.i("TAG", "The task is"+getTaskId());secondButton.setOnClickListener(new OnClickListener() {@Overridepublic void onClick(View v) {// TODO Auto-generated method stubIntent intent = new Intent(MainActivity.this,SecondActivity.class);startActivity(intent);}});}
protected void onCreate(Bundle savedInstanceState) {// TODO Auto-generated method stubsuper.onCreate(savedInstanceState);requestWindowFeature(Window.FEATURE_NO_TITLE);setContentView(R.layout.activity_second);Log.i("TAG", "The task is"+getTaskId());Button thirdButton = (Button)findViewById(R.id.third_button);thirdButton.setOnClickListener(new OnClickListener() {@Overridepublic void onClick(View v) {// TODO Auto-generated method stubIntent intent = new Intent(SecondActivity.this,ThirdActivity.class);startActivity(intent);}});}}
protected void onCreate(Bundle savedInstanceState) {// TODO Auto-generated method stubsuper.onCreate(savedInstanceState);requestWindowFeature(Window.FEATURE_NO_TITLE);setContentView(R.layout.activity_third);Log.i("TAG", "The task is"+getTaskId());Button firstButton = (Button)findViewById(R.id.firstButton);firstButton.setOnClickListener(new OnClickListener() {@Overridepublic void onClick(View v) {// TODO Auto-generated method stubIntent intent = new Intent(ThirdActivity.this,MainActivity.class);startActivity(intent);}});}}

android基本知识(一)的更多相关文章
- Xamarin Android教程Android基本知识版本介绍与系统介绍
Xamarin Android教程Android基本知识版本介绍与系统介绍 Xamarin Android教程Android基本知识版本介绍与系统介绍,开发Andriod有时候不像iOS一样轻松,因为 ...
- [转]【eoeAndroid索引】史上最牛最全android开发知识汇总
一.开发环境搭建 (已完成) 负责人:kris 状态:已完成 所整理标签为:搭建 SDK JDK NDK Eclipse ADT 模拟器 AVD 调试器(DEBUG) DDMS 测试 日志 Logca ...
- Android基本知识
Android是Google公司于2007年发布的基于Linux内核的手机操作系统.应用层主要以java为编程语言,应用层分为两层,函数层(Library) 和虚拟机(Virtual).中间 ...
- 【Xamarin开发 Android 系列 4】 Android 基础知识
原文:[Xamarin开发 Android 系列 4] Android 基础知识 什么是Android? Android一词的本义指“机器人”,同时也是Google于2007年11月5日宣布的基于Li ...
- 第01讲- Android背景知识
第01讲Android背景知识 Android是基于Linux系统 Android系统框图 : 第一.操作系统层(OS) 第二.各种库(Libraries)和Android 运行环境(RunTime) ...
- 写给Android App开发人员看的Android底层知识(1)
这个系列的文章一共8篇,我酝酿了很多年,参考了很多资源,查看了很多源码,直到今天把它写出来,也是战战兢兢,生怕什么地方写错了,贻笑大方. (一)引言 早在我还是Android菜鸟的时候,有很多技术我都 ...
- 打造自己的Android常用知识体系
前言 Android常用知识体系是什么鬼?所谓常用知识体系,就是指对项目中重复使用率较高的功能点进行梳理.注意哦,不是Android知识体系. 古语道:学而不思则罔,思而不学则殆.如果将做项目类比为“ ...
- Android基础知识巩固:关于PendingIntent和广播
平时使用广播的场合比较多,但细节的东西,看过了也没有总结,以至于某些场合有小问题,还是要把原理和属性搞清楚才能运用自如. 其实也是自己比较懒,先看别人的blog,有个概念再去官网看英文的能好理解一些. ...
- Android基础知识-1
1.Android的Activity任务栈 在Android的系统中,在APP运行时每个APP都会默认有一个任务栈,任务栈的名称以APP的包名命名.任务栈是一中先进后出的结构,APP中每一个调用的Ac ...
随机推荐
- [OC Foundation框架 - 3] 指向指针的指针
使用函数改变NSString void changeStr2(NSString **str3) { *str3 = "; } int main(int argc, const char * ...
- iOS - Xcode升级到5.1& iOS升级到iOS7.1问题:Undefined symbols for architecture x86_64
Xcode升级到5.1 新特性之一就是默认让所有App都通过64位编译器编译.原来在Xcode5.0.x的时候默认的Standard architectures只有(arm7,armv7s),到5.1 ...
- 如何使用Keil仿真环境查看CPU类型字长?【worldsing笔记】
笔者上次写了如何用IAR查CPU的字长和数据类长度的方法:点击这里查看 今天试着在Keil MDK 5.0 里查看CPU的字长和数据类长度,打开一个已有的工程,编译并进入Debug,如图1.1所示: ...
- css控制内容显示,自动加"..."
.css{ overflow:hidden; white-space:nowrap; text-overflow:ellipsis; width:100px; } c ...
- 【STL源码学习】细品vector
第一节:vector简介 vector是一种典型的类模板,使用的时候必须进行实例化. vector的数据存储在数组上,支持随机访问迭代器,支持下标操作[]和at操作,支持手动扩容和自动容量增长. ve ...
- DONET三层架构开发初步
.NET三层架构开发初步 今天咱们来谈下三层架构.说到三层架构,搞过点程序的可能都知道三层架构的概念.但是对三层的精髓可能不是很了解. 首先说下自己对三层的理解,就是使用三个(多个)项目结合起来开发出 ...
- 查看linux中的TCP连接数【转】
转自:http://blog.csdn.net/he_jian1/article/details/40787269 查看linux中的TCP连接数 本文章已收录于: 计算机网络知识库 分类: ...
- 使用ApplicationLoader中出现报错:The IPA is invalid. It does not inlude a Payload directory
问题处理方法: 1.将achieve的.app后缀的软件包放在一个payload的文件夹中 2.压缩该文件夹,改变.zip后缀为.ipa 3.使用applicationLoader上传该文件
- cocos2d-x 开发时的注意点
转自:http://cjhworld.blog.163.com/blog/static/20707803620132693629307/ 1. 按照Cocos2d的编程风格,尽量少用构造函 ...
- android获取mac地址方法
http://www.cnblogs.com/xioapingguo/p/4037513.html 网上找的,记录一下 public static String getMacAdress(){ Wif ...