06 Activity显示跳转
<span style="font-size:18px;">package com.fmy.day8_29task; import com.fmy.day8_29task.util.MyTaskUtil; import android.app.Activity;
import android.content.ComponentName;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View; public class MainActivity extends Activity { @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
} @Override
protected void onResume() {
// TODO Auto-generated method stub
super.onResume();
MyTaskUtil.printStack(getApplicationContext());
} public void second(View v) {
startActivity(new Intent(this,Second.class));
}
public void first(View v) {
//显示跳转制定类名无须遍历整个全部手机清单文件 效率高
/**
* 方式一
* 显式跳转 new Intent(this,Second.class);
* 实际调用componentName(this,Second.class)
* 效率高
*/
//Intent intent = new Intent(this,Second.class);
//startActivity(intent); /**
* 方式二
* 显式跳转 intent.setClass(this, Second.class);
* 实际调用componentName(this,Second.class)
* 效率高
*/
//Intent intent = new Intent();
//intent.setClass(this, Second.class);
//startActivity(intent);
/**
* 方式三
* 显式跳转
* 效率高
*/
Intent intent = new Intent();
ComponentName componentName = new ComponentName(this, Second.class);
intent.setComponent(componentName);
startActivity(intent);
/**
/**
* 方式四
* 显式跳转 跳转另一个程序的 界面
* 效率高
* 第一个参数 程序包名 第二个参数 某个Activity所在的包名.类名
*/
Intent intent = new Intent();
intent.setClassName("com.fmy.day8_29task", "com.fmy.day8_29task.Second");
//如果类在的包为com.fmy.day8_29task 可以写成
//intent.setClassName("com.fmy.day8_29task", ".Second");
startActivity(intent);
} }</span>
技巧:查看某个其他程序的一个界面地址,打开某个程序的界面。查看logcat
总结:显示跳转效率较高 不用遍历手机所有清单文件
06 Activity显示跳转的更多相关文章
- 设置Activity显示和关闭时的动画效果
设置Activity显示和关闭时的动画效果 通过overridePendingTransition方法可以设置Activity显示和关闭的动画效果.首先需要在res/anim目录中建立相应的动画资源文 ...
- android_定义多个Activity及跳转
说明:在Android应用程序其中创建多个activity,而且启动一个activity的方法,以及activity之间的跳转. 样例:在MainActivity里面加入一个button,触动butt ...
- 06 Activity的启动模式 Intent的七大属性的总结
1.Task以及back stack >Task(任务) 为了完成一个功能 多个Activity的集合, 当你的应用程序启动时 系统会自动创建Task用于管理Activity ...
- Activity基本跳转
详细解释:http://blog.csdn.net/xiazdong/article/details/7664757 简单介绍activity的跳转,通过intent实现,详细的注释在代码中.涉及到a ...
- 5.10学习总结——Activity的跳转和传值
使用sharedpreference是对信息的存储,也可以进行传值,今天通过查找资料,学习了Activity的跳转和传值方法. 跳转 1.显示跳转 4种方法 1 2 3 4 5 6 7 8 9 10 ...
- Android课程---Activity的跳转与传值(转自网上)
Activity跳转与传值,主要是通过Intent类来连接多个Activity,以及传递数据. Intent是Android一个很重要的类.Intent直译是“意图”,什么是意图呢?比如你想从这个 ...
- Android activity界面跳转动画
实现activity界面跳转动画 1.在startActivity方法之后加入: overridePendingTransition(R.anim.pull_in_right, R.anim.pull ...
- Activity的跳转与传值(转载)
Activity跳转与传值,主要是通过Intent类来连接多个Activity,以及传递数据. Intent是Android一个很重要的类.Intent直译是“意图”,什么是意图呢?比如你想从这个 ...
- android入门:activity之间跳转,并且回传参数
介绍: 两个activity进行跳转,在跳转过程中,将message由MainActivity传递到secondActivity,并且当secondActivity退回至MainAct ...
随机推荐
- SpringBoot跨域问题解决方案
一.允许全部请求跨域许可的代码: 需要继承WebMvcConfigurerAdapter类 @Configuration public class MyWebAppConfigurer extends ...
- shell 报错:syntax error: unexpected end of file
有时执行脚本时会报错: [root@host1 shell]# sh -x test.sh + $'\r' : command not found test.: syntax error: unexp ...
- TensorFlow 聊天机器人开源项目评测第一期:DeepQA
聊天机器人开源项目评测第一期:DeepQA https://github.com/Conchylicultor/DeepQA 用 i5 的笔记本早上运行到下午,跑了 3 轮的结果,最后效果并不理想.官 ...
- Android.mk 详解
Android中增加本地程序或者库,这些程序与其所在路径没有关系,只和它们的Android.mk有关系. Android.mk与普通的makefile略有不同,Android.mk具有统一的写法,主要 ...
- Ubuntu一些常用的软件安装及配置
软件 安装 Vim echo "y" | sudo apt-get install vim 安装搜狗输入法 这个我在虚拟机里面尝试了好多遍,不断恢复备份然后重试.终于有了这个纯靠命 ...
- SQl语句中使用占位符的优点
1.增加SQL代码可读性2.占位符可以预先编译,提高执行效率3.防止SQL注入4用占位符的目的是绑定变量,这样可以减少数据SQL的硬解析,所以执行效率会提高不少 绑定变量是Oracle解决硬解析的首要 ...
- vue开发中遇到的问题集锦(2)
1,在搭建了一个vue的脚手架之后,写了第一个组件,路由也已经配置完毕,且页面的路由显示是:http://localhost:8080/#/userLogin,userLogin里面有内容,但是页面显 ...
- JVM内部原理
这篇文章详细描述了Java虚拟机的内在结构.下面这张图来自<The Java Virtual Machine Specification Java SE 7 Edition>,它展示了一个 ...
- Spring错误之org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'bookService' is expected to be of type 'pw.fengya.tx.BookService' but was actually of type 'com.sun.proxy.$Proxy1
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'cas ...
- Luxurious Houses
The capital of Berland has n multifloor buildings. The architect who built up the capital was very c ...